Created
December 26, 2014 18:25
-
-
Save Depicus/8e83b0609b72aeff3c00 to your computer and use it in GitHub Desktop.
Use Gravatar avatars from php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$email = md5(strtolower("[email protected]")); | |
$gravatar = "http://www.gravatar.com/avatar/$email?d=404&s=50"; | |
$headers = get_headers($gravatar,1); | |
if (strpos($headers[0],'200')) echo "<img src='$gravatar' style='border-radius: 25px;'>"; // OK | |
else if (strpos($headers[0],'404')) echo "No Gravatar"; // Not found we could show a default image here | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment