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.
i will try this out, been meaning to do this for ages!
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.
How should this be added to existing themes? Is there any sample code of how it would normally be added to a theme?
Oh ye! I wanted to use Gravaters on my blog for ages but I’m so lazy. Looking forward to stable 2.5.
what if we want to use MyBlogLog avatars?
Christopher: click on the documentation link in Ryan’s post…
Cooool 🙂
Social WordPress is coming!
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.
@Jenny
It will require a plugin, but this will be possible in 2.5.
Yay!
Have a look at lines 66-68 of Tarski’s comments.php file for an example of this in action.
I want to use MyBlogLog avatar
Great news, looking forward to the new release
Hmm, will it let me /add/ a service /as well/ as gravatar? Will have to experiment.
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.
very nice.
This code was postd to WP testers, I triied it out and it works for me quite nicely on my test site:
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.
pretty damn cool…
with the brand new dashboard~~
cool feature!
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?
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?