If you've been using Wordpress you probably know about Gravatar. Gravatar is an abbreviation for "Globally Recognized Avatar". It's a service which provides an avatar across sites. While Gravatar support is built-in in Wordpress, it requires an external module to be installed in Drupal. Recently I had to use the module in a Drupal 5 instance.
The module provides a gravatar only for comments. You can have the module insert the gravatar into the comment body itself or have it provide a field in the comment object ($comment->gravatar) which can be used by the theme. It does this by using the hook_comment() .
In our case though, we needed it to show the gravatar instead of the user picture if the user had not uploaded any. This was very easy to do. The key function here is _gravatar_get_gravatar(). You can provide it any or all of these parameters - mail, default, size or rating. Mail is the email id of the user. Gravatar can supply a unique generated avatar in case the email id you send them is not that of a registered Gravatar user. This can be of many types - identicon, wavatar or monsterid. Which of these are what you want, is specified in the default parameter. The size is of course, the size. The gravatars uploaded come with a rating - G, PG, R or X. You can specify a maximum rating with the rating parameter. You can read more about the gravatar parameters.
You can pass whichever of these parameters you want to _gravatar_get_gravatar() and it will return to you the url of the gravatar. Now pass this to the theme_gravatar() function in the gravatar module.