Avatars in WordPress 2.5

March 4, 2008
tags:
by Ryan

Weblog Tools Collection has documented the get_avatar() function present in WordPress 2.5 so that I don’t have to. Big thanks. I can scrap the avatar post I haven’t got around to writing and instead answer some of the questions that popped up in the comments to the WTC post.

Gravatar is the service used by default. get_avatar() is completely pluggable, however, so any service can be used. get_avatar() is built-in so that themes will have some fixed API on which they can rely, regardless of whatever avatar service is being used behind-the-scenes.

In addition to accepting an email address or user ID, get_avatar() accepts an entire comment object. This is a convenience for using get_avatar() in the comments loop.

The avatar support in 2.5 does not attempt to add avatars into your existing themes. Themes must be written to use get_avatar(). Dynamic addition of avatars is left to plugins.

Avatars are displayed in several places in the admin. They will show up when managing comments, for example.

Display of avatars can be completely turned off via a preference. When turned off, no attempt is made to connect to an avatar service.

36 Responses
  1. March 4, 2008

    i will try this out, been meaning to do this for ages!

  2. March 4, 2008

    This is so awesome. I’m very glad to see Gravatar-by-default in WordPress, and I look forward to seeing what sorts of plugins are created making use of the new functionality.

  3. March 4, 2008

    How should this be added to existing themes? Is there any sample code of how it would normally be added to a theme?

  4. March 4, 2008

    Oh ye! I wanted to use Gravaters on my blog for ages but I’m so lazy. Looking forward to stable 2.5.

  5. March 4, 2008

    what if we want to use MyBlogLog avatars?

  6. March 5, 2008

    Christopher: click on the documentation link in Ryan’s post…

  7. March 5, 2008

    Cooool :)

    Social WordPress is coming!

  8. March 5, 2008

    I really need some examples not snippets by themselves…. something that says insert x code before or after x on the index/home.php etc.

  9. March 5, 2008

    @Jenny

    It will require a plugin, but this will be possible in 2.5.

  10. March 6, 2008

    Yay!

  11. March 6, 2008

    Have a look at lines 66-68 of Tarski’s comments.php file for an example of this in action.

  12. March 6, 2008

    I want to use MyBlogLog avatar

  13. March 7, 2008

    Great news, looking forward to the new release

  14. March 8, 2008

    Hmm, will it let me /add/ a service /as well/ as gravatar? Will have to experiment.

  15. March 8, 2008

    If you wanted to use myBlogLog with this new function, you would need to use a plugin to do so. As of yet there hasn’t been on written.

    If you’re wondering why it uses Gravatars, let’s not forget who owns Gravatars now.

  16. March 9, 2008
    stoph permalink

    very nice.

  17. March 16, 2008

    This code was postd to WP testers, I triied it out and it works for me quite nicely on my test site:


  18. March 20, 2008

    How about caching of the avatars? I just recently started to use Gravatar2 plugin which caches the images from gravatar.com which is nice feature. Any info on caching in wp2.5? Btw I tested wp2.5RC1 and so far been liking it. Just hope this avatar/gravatar feature won’t be messed up.

  19. March 30, 2008

    pretty damn cool…
    with the brand new dashboard~~

  20. March 30, 2008
    kurosaki permalink

    cool feature!

  21. April 27, 2008

    Most of my blog’s readers are in China, to them, it is too slow to download the avatar pics. But i think avatar pics are very cute, still want to use this features. What should I do? Does this kind of plugins exist, that it can cache every avatar pics on the local server?

  22. May 1, 2008

    Hi, I was wondering if anyone’s had any issues with the avatar-default class being assigned if the default image is used. Ryan, I notice that’s what’s happening here on your site, but for some reason, that class is not being assigned to my default avatars when they’re displayed.

    Basically I’m trying to hide the image completely if the default image is displayed, instead of displaying anything. I tried using a blank transparent GIF, but then the text wraps around an empty space. Anyone know how to hide the avatar completely if the default is shown?

Trackbacks & Pingbacks

  1. Weblog Tools Collection » Blog Archive » Gravatars and WordPress 2.5
  2. Gravatars available in WordPress 2.5 by default! » BoltPress
  3. Ideile Mele » Blog Archive » Avatare in WP 2.5
  4. Gravatars included in upcoming WordPress release « one cool site
  5. Liten sniktitt på WordPress 2.5 · Fru W.
  6. WordPress Wednesday News: WordPress 2.5 Next Week, WordPress Goes Social, Cleaning Out Splogs, and More WordPress News : The Blog Herald
  7. Gravatars and WordPress 2.5 | OPOWAE
  8. New Features in WordPress 2.5 | UC2
  9. geek ramblings » Easy Gravatars 1.2
  10. Easy Gravatars 1.2 : e-Spot.se
  11. WordPreciousss 2.1.2, support forum and ideas for the future | WordPreciousss
  12. WordPress 2.5 and Gravatar | 中国特色。NET
  13. Upgraded to WordPress 2.5 | K-Squared Ramblings
  14. SamuelPhotos Blog » Blog Archive » Avatar support in WordPress 2.5

Comments are closed for this entry.