How to Change Avatar Size in WordPress Comments

I wanted to increase avatar size (Gravatar) in my WordPress comments, but any amount of CSS tweaking for the avatar size would not work. I realized the avatar size was generated hardcoded in HTML and there was no way to change that.

In my WordPress themes, the small avatar image was not blending with the bold look of the theme, and this is the way I fixed this.

Relook Comments.PHP File

A quick view at your comments.php file would reveal that the comments are output by this code.

<ol class="commentlist">
<?php wp_list_comments(); ?>

Note that we had set the type argument to show comments only (not pingbacks / trackbacks) so our code looks like this right now

<ol class="commentlist">
<?php wp_list_comments(array('type' => 'comment')); ?>

Change Avatar Size

So wp_list_comments is the target file that generates the hardcoded avatar size of 32x32px.

I wanted to increase the avatar size to 48x48px, so here is how I modified the code to look like this.

Change the 48 to any size you like from 1-512.

<ol class="commentlist">
<?php wp_list_comments(array('avatar_size' => '48', 'type' => 'comment')); ?>

Now we are showing comments with an avatar size of 48x48px. Post a comment and try for yourself. (Obviously, you have a gravatar by now with the same email address or your avatar would not show on any site).

Share with friends

About the Author: P Chandra is editor of QOT, one of India's earliest tech bloggers since 2004. A tech enthusiast with expertise in coding, WordPress, web tools, SEO and DIY hacks.