function avatar( $uid, $email, $size ) {
$local_exists = file_exists( "uploads/avatar_$uid.gif" );
if ( !$local_exists ) {
$default = "/uploads/avatar_.gif";
$url = "http://www.gravatar.com/avatar.php?gravatar_id=".md5( strtolower($email) )."&default=".urlencode($default)."&size=".$size;
}
else {
$url = "/uploads/avatar_$uid.gif";
}
return $url;
}
I'm sure there are better ways to do this (without hardcoding urls and paths, for example), but this is simple enough that I thought it could save others some time, perhaps. I should note that my $uid is a unique database id associated with each user.

Help













