WP 2.5 has built-in gravatar support

Seems that WordPress v2.5 (which will be out this month) will include support for Gravatars by default:

default avatarTheme Authors: Adding Gravatars to Your Theme

The function to add Gravatars to your theme is called: get_avatar. The function returns a complete tag of the Avatar.

The function get_avatar is setup as follows:

function get_avatar( $id_or_email, $size = '64', $default = '' )

* id_or_email: The author’s User ID (an integer or string) or an E-mail Address (a string)
* size: The size of the Avatar to display (max is 80).
* default: The absolute location of the default Avatar.

That’s the default avatar icon up there. Ugh. I am really not interested in gravatars, I am a fan of Monster ID and Wavatars. I hope Scott and Shamus can update their plugins to hook into the native 2.5 functionality as that would be a lot simpler. Adding a dropdown to the Admin panel to let you select between different icon sets is probably the best approach.

UPDATE: Ryan Boren says that any avatar service can be invoked, not just Gravatar:

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.

2 thoughts on “WP 2.5 has built-in gravatar support”

  1. I didn’t know about that. From a quick look at the nightly builds, it looks like they implemented it pretty well. First, the get_avatar function is in pluggable.php (all functions inside if (!function_exists( $functionName)) :) so a plugin can just define the function and automatically overwrite the default function. Also, they include a nice filter to catch the default gravatar output and overwrite or mess with it (apply_filters('get_avatar', $avatar, $id_or_email, $size, $default);). It looks like a plugin could hook into that filter and check if $avatar contained $default and if so change to a plugin generated avatar (or just rewrite all avatar’s to use plugin generated ones if you don’t like gravatar).

    I’m still surprised gravatar hasn’t implemented their own default avatar generation. It’s really nothing special and even if they don’t want to code it themselves there’s a bunch of open source ones out there.

  2. awesome – i look forward to your next update 🙂 I like the idea of choosing between using an alternate avatar service for all avatars OR letting the custom avatar kick in only if theres no default. To be honest I am not sure which way Id go. I love my Monsters 🙂 Maybe I should create a Gravatar with my Monster… heh.

Comments are closed.