RaBu.dk - Website and weblog of Rasmus Burkal

Gravatar, what is it and how does it work?

Posted on the 22.03.2010 at 00:01 by Rasmus Burkal

Gravatar is an web service, providing users the opportunity of hosting a global accessible avatar, based on the users e-mail address.

The advantage of Gravatar from the user perspective, is the ability to centralize and reuse the same avatar across several websites. This also gives the user the advantage of changing the avatar only once, then it will be automatically updated everywhere it has already been used.
From website owners perspective, the advantage is to “outsource” all the handling (uploading, hosting etc.) of the avatars to Gravatar. From a usability perspective, it also makes it more efficient for the website visitors, to reuse an existing avatar, instead of forcing the user to upload a new avatar on every website.

Gravatar can be used by any website or webapp, e.g. it is default in WordPress and available as a 3. party module to Drupal. If you don’t use WordPress or Drupal, you can integrate Gravatar into your site yourself, here is how it works:

The avatar is based on the users e-mail address, and as you know e-mail addresses are unique, but for security and anti-spam purposes the e-mail address is not used as the reference to the avatar, instead an md5 hashed value of the e-mail address is used. So e.g. for my e-mail address this will be the unique id of my avatar: 3fa4f64aa0eef0f1337da9288c238ccc

Here is a shot code-example, in PHP of how to generated the md5 hash and calling the web service (http://www.gravatar.com/avatar/):

<?php
$email = "someone@domain.com";
$hash = md5(strtolower($email));
?>

<img src=”http://www.gravatar.com/avatar/<?php echo $hash ?>” />

This is an example of a generated Gravatar URL: http://www.gravatar.com/avatar/3fa4f64aa0eef0f1337da9288c238ccc
Note: It’s important to generated the md5 hash, based on the lowercased e-mail address!

This is just a very basic example, please visit Gravatars documentation on how the URLs should be constructed.

One of my questions regarding this, is why don’t more websites and webapps used this service? If you know of any big websites or open source projects using Gravatar, please leave a reply!

Personally I think it would be fun, to see site like DailyBooth integrating with Gravatar, so users could use their daily photo as their avatar. Or even Twitter and Facebook, could integrate with Gravatar – for users, to use their avatar as their profile picture, or the other way around!

Bookmark and Share

Comments

There are no comments yet.

Leave a reply

To leave a reply, you must be logged in.