Second Pass at Avatar Plugin (MBLA plus)

A little while ago Alper Çuğun released an hAvatar plugin, which parses the url left by a comment author, and if it finds an hCard there, looks for an image in the hCard. This is a nice step towards URL-based identifiers rather than email based ones.

However, I also wanted to show avatars for users who use Gravatar or MyBlogLog.

The solution, for me at least (and for now) was to take Jan Olsen‘s excellent MBLA plugin and hack it up a bit. I took out the “Google Preview” functionality, and added in support for the hAvatar plugin. (MBLA already handled Gravatar and MyBlogLog, and had a nice caching system to boot, so it made a nice place to start).

So, if you leave a comment below, it should do the following:

  1. If you leave a url in the url field (doesn’t have to be an OpenID, but it can be), and there is an hCard living at that url, and that hCard has a photo, it should be retrieved.
  2. If you don’t provide a url, or the url you provide doesn’t have an hCard at it, or that hCard doesn’t have an image in it, then your email address will be checked at both MyBlogLog and Gravatar
  3. If you don’t provide a url or an email address, you won’t get an avatar associated to your comments

There’s also caching, thanks to MBLA’s nice framework, currently set to just 1 day, for testing – I will pump it to longer timeframe once I’m convinced it all works.

If you’d like a copy lemme know – once I’ve tested a bit I will publish the code.

← Previous post

Next post →


  1. That sounds great John!

    Be sure to add your plugin to the implementations page on the microformats wiki when you’ve published it:

    Looking forward to trying it out.


  2. Cool! So how modular is this? What if hAvatar is upgraded (which it will)?

    And can I download/use this code from you?

  3. Hmm. Tantek somehow got my photo (sorry Tantek). Seems to be passing in my email address when users leave that blank – maybe a missed initialization step somewhere. Back to debug.

    Cristiano’s worked. But he provided an email.

    It is separate from hAvatar (I’m sure the bug is in my changes), so that if hAvatar gets updated that’s easy – it isn’t, however, cleanly separate from MBLA.

    Once I get it actually working well and reliably, I will make it available for download.

  4. John,

    Indeed, I shouldn’t have to provide an email address if I provide my URL as OpenID right?

    Note: I’m using delegation to to use as my OpenID but it doesn’t appear to have been recognized as an OpenID in my first comment.

    In this comment I’m leaving the “Name” field blank as well, as your plugin should be able to get my “fn” from my hCard at my URL. You may want to take a look at the “representative hCard” page to make sure your plugin is retrieving the representative hCard from my URL.

    Ideally, all a commenter should have to enter is their Website URL which both contains their hCard (with name and photo) and acts as their OpenID.



  5. Ok, dealt with the issue when email is blank. But still no icon for Tantek.

    But it looks like this is an issue with the parsing inside hAvatar since it fails there too.

  6. Tantek – you’re right, of course.

    Right now the hAvatar plug-in isn’t parsing all that stuff out of the hCard.

    Not sure why it isn’t recognizing your url as an OpenID – that’s the wp-openid plug in from the DiSo project. Maybe the MBLA/hAvatar and the wp-openid are conflicting?

    Thanks for taking a look


  7. Looking forward to its release! Thank you for your hard work.