nathan15

My Gravatar PHP Function

Jun 1st, 2014
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.65 KB | None | 0 0
  1. // If you'd like to implement Gravatar on your site and want a simple function to use,
  2. // feel free to use this function I made for some of my sites.
  3.  
  4. // Example - Default settings:
  5. // <img src="<?php echo gravatarURL($userEmail); ?>" />
  6.  
  7. // Example - Custom size, default image, and rating:
  8. // <img src="<?php echo gravatarURL($userEmail, 100, 'http://some-site.com/images/default_user.png', 'g'); ?>" />
  9.  
  10.  
  11. function gravatarURL($email, $size = 80, $defaultImage = "identicon", $rating = "pg") {
  12.     $emailHash = md5(strtolower(trim($email)));
  13.     $url = "http://gravatar.com/avatar/{$emailHash}?s=$size&d=$defaultImage&r=$rating";
  14.     return $url;
  15. }
Advertisement
Add Comment
Please, Sign In to add comment