Introduction
One of the easiest way to add user avatars to your website is to use the gravatar.com service.
Using PHP
This is an example of Gravatar implementation using PHP.
If you are storing user e-mails (or at least e-mail md5 hashes), you can obtain an avatar associated with it by calling an URL on the gravatar server with an md5 hash of the user's e-mail address.
What does hashing mean? It means you apply the md5() function on the e-mail value. It's actually very simple:
$email = 'me@example.com'; $emailHash = md5($email); $gravatarUrl = sprintf('http://www.gravatar.com/avatar/%s', $emailHash); $img = sprintf('<img src="%s" />', $gravatarUrl); print $img;