hAvatar Wordpress Plugin

Posted by alper

I had the idea for a Wordpress plugin replacing the avatar systems of gravatar and MyBlogLog with a microformat based one a while back.

The principle is simple. If you comment somewhere and you leave behind a URL (be it a blog one or an OpenID) and we can follow that URL and find a representative hCard with associated picture for you, it means we can present that picture as your avatar.

It works just as well as most avatar standards out there, it’s distributed and built on top of a proven microformat and gives people a benefit for publishing an hCard on their blog or elsewhere.

Development

havatar

Writing that plugin didn’t prove to be too difficult. Integrating Drew McLellan’s hKit library into Wordpress was a bit harder due to my limited experience with PHP and its bizarre quirks.

That hurdle passed I have been using the plugin on my own blog and Cristiano is using it as well. We’ve only had problems running it on this weblog most probably because something on the Solaris installation we are running is interfering (I have no clue what). You can test the plugin yourself on this test weblog.

There are some ideas in here which are similar to those of DiSo in their wishlist for a wp-openid-avatars plugin.

Release

After having spent some due dilligence testing and refining this plugin, I think it’s ready to be released and tested by a larger group of people. The plugin will not do much without you editing your theme as well and making a decision about the presentation of the avatar images.

Alternatively if gravatar() is not defined yet, it will define itself as the gravatar function as well. So a theme which relies on gravatar can expect this plugin to support it.

Get a zip with the plugin in it here, or you can checkout my repository:
hg clone static-http://alper.nl/hg/havatar/

Feedback, suggestions and patches welcome. Caching and resizing are issues that have to be solved in the future.

I found a plugin called identikit which covers a lot of the same ground but is mostly in French. hAvatar is a simple and pure microformats based approach.

15 Responses to “hAvatar Wordpress Plugin”

  1. Pfefferle http://notizblog.org

    Hello alper,

    I tested your plugin with my hCard-Commenting plugin and get a fatal error, because we both use the hKit class.

    If we both add the folowing code, it works fine:

    if (!class_exists(’hKit’)) {
    include_once(dirname(__FILE__) . ‘/hkit.class.php’);
    }

    Nice plugin, well done.


  2. Warning: array_key_exists() [function.array-key-exists]: The second argument should be either an array or an object in /home/fourstar/public_html/wp-content/plugins/hAvatar/hAvatar.php on line 40

    Warning: array_key_exists() [function.array-key-exists]: The second argument should be either an array or an object in /home/fourstar/public_html/wp-content/plugins/hAvatar/hAvatar.php on line 42
    Alcides

    Alcides http://alcides.ideias3.com

    It would be cool if you add hAvatar to the microformats wiki, since I cannot find a documentation page (yes, I know it’s too damn simple, but I am currently using this URL for linking).

    Second, what about a openid wordpress plugin here ;)

  3. Cristiano Betta http://cristianobetta.com/

    Yeah we know about the OpenID non-support on FS> Problem is that this server runs some weird version of PHP that makes it impossible to run both hAvatar and WP-OpenID. We are thinking of moving server because obviously we want to be able to run both plugins on our site :D


  4. Warning: array_key_exists() [function.array-key-exists]: The second argument should be either an array or an object in /home/fourstar/public_html/wp-content/plugins/hAvatar/hAvatar.php on line 40

    Warning: array_key_exists() [function.array-key-exists]: The second argument should be either an array or an object in /home/fourstar/public_html/wp-content/plugins/hAvatar/hAvatar.php on line 42
    Alcides

    Alcides http://alcides.ideias3.com

    Since one URL may have more than one hCard, how do you identify which one is the author’s?

    From the code, I got you are using the first one, but that’s not always the right one. The brainstorming around hCard autodiscovering (http://microformats.org/wiki/hcard-brainstorming-autodiscovery) is pointing class=”author” as the probable main identifier. However hKit (or Mofo for Ruby) don’t record that information. So for now, we would have to get some parsers for that, right?

    And another problem is that it will take a while for people to change this in their hCards, so at the present there is no way of knowing which one is the author of the URL. I have done some tests and the hCard with the higher number of fields seem to be the author of the webpage, but that’s not 100% correct. How are you thinking of improving the hCard discovery in hAvatar plugin?

  5. alper http://www.alper.nl

    @Pfefferle: I’ll implement that fix.

    @Alcides: I created a page on the uf wiki and it got refactored: http://microformats.org/wiki/hAvatar

    @Alcides: Representative discovery is the way to go and if parsers currently do not return that information, the parsers need to be adjusted. By extension the properties used for this semantics would also be microformats and microformats parsers should return them.

    For now, I think it’s cool enough if people have 1 hCard on a URL they see as their primary identity. Small steps.

  6. John Eckman http://johneckman.com/

    Seems to have some unpredictable behavior when passed a url which doesn’t have an hcard - throws up some errors as it tries to parse things which aren’t hCards - maybe the issue is if the url returns things which aren’t even valid html?

    I’ll poke around and test some more to see what I can reproduce.

  7. alper http://www.alper.nl

    @John: It would be nice indeed if you could reproduce some stuff. In most cases where no hCard is found it returns the default image. hAvatar uses hKit for parsing so if the error is in there we should take it upstream.

  8. Cristiano Betta http://cristianobetta.com/

    I still get the occasional warnings. Lately it is:

    Warning: array_key_exists() [function.array-key-exists]: The second argument should be either an array or an object in /home/cristiano/public_html/theblog/wp-content/plugins/hAvatar/hAvatar.php on line 37

    Warning: array_key_exists() [function.array-key-exists]: The second argument should be either an array or an object in /home/cristiano/public_html/theblog/wp-content/plugins/hAvatar/hAvatar.php on line 39

  9. John Eckman http://johneckman.com/

    The issue is that it throws errors when the doc isn’t valid xml - I used http://www.jotyler.com/ for testing to reproduce, but should happen with any invalide xml doc

  10. Cristiano Betta http://cristianobetta.com/

    By the way: hAvatar now also works on http://Missgeeky.com!

  11. Walter Logeman http://psyberspace.wordpress.com

    I wonder will this show my hcard?

  12. Cristiano Betta http://cristianobetta.com/

    @Walter, well, not here definitely. Having some issues with this server.

::Trackbacks::

  1. hCard Delegation at notizBlog - a private weblog written by Matthias Pfefferle

  2. Second Pass at Avatar Plugin

  3. Микроформати и WordPress | Блогът на Гонзо

Leave a comment:

(name)

(email)

(website)

Fields marked with * are required
Email will not be published