Gravatar

Gravatar

From SwitchBL8's wiki

Jump to: navigation, search
<?php
       // the email address you registered with Gravatar.com
       $email = "your_email@somecompany.com";
       // Default avatar-location if somehow the Gravatar can not be generated (e.g. rating higher than allowed rating)
       $default = "http://www.somecompany.com/homestar.jpg";
       // Gravatar size ( $size x $size)
       $size = 80;
       //
       //You can construct your gravatar url with the following php code:
       $grav_url = "http://www.gravatar.com/avatar.php?gravatar_id=".md5($email)."&default=".urlencode($default). "&;size=".$size;
       //
       // Optionally you can add the following:
       // MPAA rating. Maximum allowed category of Gravatar: G, PG, R or X
       $grav_url = $grav_url."&rating=X";
?>

Now you can show the Gravatar in your pages by including:

<img src="<?php echo $grav_url; ?>" alt="" />