HOWTO change avatar size in WordPress

The Problem:
The default icon size of the avatar in WordPress is too small. (Go directly to step 4, if you’re in a hurry)
As a WordPress novice I’ve been looking for a switch to change the avatar size, but I couldn’t find any. If you login as SiteAdmin and go to Settings->Discussion, there’s only the possibility to choose between

  • Mystery Man
  • Blank
  • Gravatar Logo
  • Identicon (Generated)
  • Wavatar (Generated)
  • MonsterID (Generated)

There’s no ruler to change the size. So I’m looking now, how to change the size for all of them.
At least not in WordPress version >=2.6.2, since this is the only version I know about. I must admit I didn’t look for any of these million plugins, which are available, and surely can do magic with and to avatars, but I like it to keep my Workpress config as simple as possible. And I’d like to keep the amount of plugins small.

The instructions I’ve found on my 5min search tour on Google, I did’t understand, or the version of WordPress differed too much.

Way of solution:

Here’s my simple approach to change the icon size of all avatars (except the ones in the Admin console).

  1. Login to your WordPress server

  2. Go to the directory where your WordPress is located. Then to the place where your theme is located. There lines below refers to a Debian installation of WordPress 2.6.3, and the theme blocks2 (not default! you’ve got to use your current used theme)

    cd /usr/share/wordpress/

  3. Save the original file first, and grep and verify the result below. It should be more or less identical. If not – don’t procede!

    cp comments.php comments.php.orig
    grep 24 comments.php

    <div class="authoravatar"> <?php echo get_avatar("", 24); ?> </div>
    echo get_avatar($comment, 24);
    gravatar("G", 24);
    <input type="text" name="author" id="author" class="textfield" value=" <?php echo $comment_author; ?>" size="24" tabindex="1" />
    <input type="text" name="email" id="email" class="textfield" value=" <?php echo $comment_author_email; ?>" size="24" tabindex="2" />
    <input type="text" name="url" id="url" class="textfield" value=" <?php echo $comment_author_url; ?>" size="24" tabindex="3" />

  4. now perform the one-liner accordingly with the size you want to have. I’ve tested 48 and 96 pixels, which work fine. This example show the change from 24 to 48 pixels avatars:

    sed -i 's/24/48/g' comments.php

If anything goes wrong, just copy back the saved file.