(+84) 463.28.7979

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 hard coded in html and there was no way to change that.

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

<ol>
<?php wp_list_comments(); ?>
</ol>

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

<ol>
<?php wp_list_comments(array('type' => 'comment')); ?>
</ol>

So wp_list_comments is the target file which generates the hard coded 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>
<?php wp_list_comments(array('avatar_size' => '48', 'type' => 'comment')); ?>
</ol>

Now we are showing comments with 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).

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>