WordPress Avatars

With Automattic acquiring Gravatar, there’s a obviously a great chance that Gravatar continues to become more and more the standard for WordPress. Until then, though, MyBlogLog still has a solid foothold in the avatar arena, and many of your blog’s readers use it faithfully. Why should you have to choose one or the other for avatars on your blog?

Now you don’t. This WordPress Avatars plugin allows you to support Gravatar and MyBlogLog avatars on your WordPress blog at the same time. It tries Gravatar first but then fails over to MyBlogLog if the commenter isn’t using Gravatar. It also allows you to specify a custom default image for those commenters who aren’t currently using either service.

There are other methods out there that do this in a much cleaner way, but those leave your readers’ email address exposed to the public in plain text — something you definitely don’t want to do.

Getting Started

  1. Download the plugin file and upload it to your /wp-content/plugins folder.
  2. Activate the plugin from the Plugins page of your WordPress control panel.
  3. Edit the comments.php file for your WordPress theme and add this line of code within the foreach ($comments as $comment) loop wherever you want the avatar to appear:<?php if(function_exists("showavatar")) showavatar(); ?>

That’s all there is to it. Please take it for a spin and let me know what you think!

Important Note

The avatar image cannot have a CSS width or padding associated with it. If you need to use either attribute, set it on a DIV surrounding the avatar IMG tag instead of on the avatar IMG tag itself. Trying to set it on the IMG will cause a Stack Overflow error in Internet Explorer and an infinite loop in Firefox.

Update Log

Version 0.55 (May 7, 2008): Removed a line of debug code that was disabling Gravatar and fixed the spelling of Alex’s name.

Version 0.6 (May 12, 2008): Fixed a bug that several people had seen where MyBlogLog wasn’t returning an image for certain URL/name combinations.

Version 1.0 (March 30, 2009): Fixed a bug that occured when a commenter used an @ sign in their name and also made a change to account for names with quotes in them.  Moved the version to 1.0 because this appears to now be a stable version.

Comments

  • Karl
    Karl

    August 5, 2008
    at 8:24 pm

    Hi, great plugin.

    I was wondering, however, if someone could post an example of how to change the avatar’s image size without breaking the plugin.

    I really need this image to be a 60×60 instead of the default 48×48.

    Thanks in advance!

    Karl


     
  • Shane
    Shane

    August 6, 2008
    at 11:22 am

    Regrettably, MyBlogLog only has a 48×48 image and doesn’t give you the option of changing it like Gravatar does. If you specified the width on the image in order to make it a different size than MyBlogLog’s default, it breaks the functionality because the plugin has to check the width of the image in order to determine which image retrievals were successful.

    So for now, we’re stuck with 48×48 if you want to be able to use both MBL and Gravatar :(


     
  • _LP
    _LP

    October 21, 2008
    at 10:37 am

    can we use the smaller icon 24×24 mbl avatar? i try to replace the 48s on your script but it didn’t work :(


     
  • Shane
    Shane

    October 21, 2008
    at 10:46 am

    No, regrettably. See the comment above yours.


     
  • Ari Herzog
    Ari Herzog

    December 27, 2008
    at 12:04 pm

    I suppose I could ask you on Twitter, Shane, but for the benefit of others who stumble across this blog post, does the plugin work with WP 2.7?


     
  • Shane
    Shane

    December 29, 2008
    at 7:48 pm

    Yep! Sure does. I’ve been running 2.7 for awhile now and have seen no issues with it.

    Thanks for asking!


     

Comment on This