gravatar.php (1087B)
1 <?php 2 /** 3 * Get either a Gravatar URL or complete image tag for a specified email address. 4 * 5 * @param string $email The email address 6 * @param string $s Size in pixels, defaults to 80px [ 1 - 2048 ] 7 * @param string $d Default imageset to use [ 404 | mm | identicon | monsterid | wavatar ] 8 * @param string $r Maximum rating (inclusive) [ g | pg | r | x ] 9 * @param boole $img True to return a complete IMG tag False for just the URL 10 * @param array $atts Optional, additional key/value attributes to include in the IMG tag 11 * @return String containing either just a URL or a complete image tag 12 * @source http://gravatar.com/site/implement/images/php/ 13 */ 14 function get_gravatar( $email, $s = 80, $d = 'mm', $r = 'g', $img = false, $atts = array() ) { 15 $url = 'http://www.gravatar.com/avatar/'; 16 $url .= md5( strtolower( trim( $email ) ) ); 17 $url .= "?s=$s&d=$d&r=$r"; 18 if ( $img ) { 19 $url = '<img src="' . $url . '"'; 20 foreach ( $atts as $key => $val ) 21 $url .= ' ' . $key . '="' . $val . '"'; 22 $url .= ' />'; 23 } 24 return $url; 25 } 26 ?>