Lets start with tutorial fetch Gravatar image using PHPFor this we will need users email address.
1) Suppose email address is “dev.xxxxx@gmail.com” then
– Make sure there are no white spaces around it, better to use php trim function.
– Convert email address to small case because MD5 is case sensitive and generates two different hash values for same email address with different case.Ex : For email address amit@gmail.com it will create hash key like “4137f5d72b8cf2ee0cad3bf00e165d5f” and for AMIT@GMAIL.COM it would create “ead586effc62adea6ae8003e717d6d22”.
2) Use php MD5 function and pass email address as a argument to that function
md5( “developer.amitpatil@gmail.com” );
it will return hash value of that email address.
now simply append generated hash key to gravatar API url. http://www.gravatar.com/avatar/Generated-HASH-key
Ex : http://www.gravatar.com/avatar/c2243b8fa53bc62c8ffd029978799ddb
Copy this url and paste in browsers address bar and you will see gravatar image.
To embed this in your web page just wrap this link with <img> tag. which will print gravatar image on your web page. like <img src=”http://www.gravatar.com/avatar/c2243b8fa53bc62c8ffd029978799ddb”> will produce image like
fetch Gravatar image using PHP
By default it displays 80X80 px image, you can customize its size by passing s= or size= parameter to the url like
<img src=”http://www.gravatar.com/avatar/c2243b8fa53bc62c8ffd029978799ddb?s=30“> will produce image like below
Lets see more examples
Thank you I like it.
I will implement this in my forums today.
if($user_defenied)
{
}
else
{// get his gravatar.
// Thank you.
}
I pay a visit day-to-day a few sites and sites to read articles or reviews, except this weblog provides quality based content.
hey ! that’s a cool tut , i like it