This article will show you the trick to set your Gravatar as your Favicon. So before moving further, have a look at article which show the method to generate Gravatar using PHP.
After following the linked article you should be able to generate your Gravatar using your email address.
We will use same technique to generate gravatar but in addition we will use this generated gravatar as Favicon for website.
Here we will create one function which generates the favicon from the gravatar for both website and apple touch icon.
This function takes two parameter first is your email address and second is the type of favicon you want. Second parameter can be either web or apple.
Let’s have a look at below code:
Code
[cc lang=”php”]
function GetFavicon($email=””,$type=”web”)
{
if($email==””)
$email = “[email protected]”;
$email_hash = md5(strtolower(trim($email)));
$link = “”;
$link.=”http://www.gravatar.com/avatar/”.$email_hash;
if($type == “web”)
$link.=”?s=16″;
echo $link;
}
[/cc]
How to use this?
Once you have placed above function in your code then here is the way how you can use this.
[cc lang=”html”]
” />
” /> “>
[/cc]
Conclusion
Hope you have enjoyed this article. Also now if you want to make you favicon dynamic then just pass the random emails to this function and its done. :)
Subscribe to our RSS Feeds to Keep your self updated.
[…] This article will show you the trick to set your Gravatar as your Favicon. PHP Read the original post on DZone… […]
Its Working good
Its Working good
What an article, I will use gravatar also to enhance my blog
What an article, I will use gravatar also to enhance my blog
What a great idea. Never thought of doing this but it makes sense now. Also makes it easier to change the icon by just updating at gravatar.com.
What a great idea. Never thought of doing this but it makes sense now. Also makes it easier to change the icon by just updating at gravatar.com.