Skip to content

Instantly share code, notes, and snippets.

@AndrewChamp
Last active December 24, 2018 06:15
Show Gist options
  • Save AndrewChamp/5957725 to your computer and use it in GitHub Desktop.
Save AndrewChamp/5957725 to your computer and use it in GitHub Desktop.
<?php
/**
* No Image Options:
* 404 - do not load any image if none is associated with the email hash, instead return an HTTP 404 (File Not Found) response
* mm - (mystery-man) Simple, cartoon-style silhouetted outline of a person
* identicon - Geometric pattern based on an email hash
* monsterid - Generated 'monster' with different colors, faces, etc
* wavatar - Fenerated faces with differing features and backgrounds
* retro - 8-bit arcade-style pixelated faces
* blank - Transparent PNG image
*
* Rating Options:
* g - Suitable for display on all websites with any audience type.
* pg - May contain rude gestures, provocatively dressed individuals, the lesser swear words, or mild violence.
* r - May contain such things as harsh profanity, intense violence, nudity, or hard drug use.
* x - May contain hardcore sexual imagery or extremely disturbing violence.
*/
function gravatar($email, $size=80, $noImage='mm', $rating='g'){
$size = $size < 10 ? 10 : ($size > 2048 ? 2048 : $size);
print '<img src="http://gravatar.com/avatar/'.md5(strtolower(trim($email))).'?s='.$size.'&amp;d='.$noImage.'&amp;r='.$rating.'" alt="" />';
}
// Example usage
gravatar('[email protected]');
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment