The images that you see next to blog comments here are not the regular gravatar pictures, instead they are favicons pulled from the website of the person who has written that comment.
Same is the case with favicons that are displayed near external hyperlinks in the tech river. With these images, you can easily figure out the target page without having to look at the browser’s status bar.
Google Shared Stuff (S2) offers a secret URL that can automatically pull favicon images of any website provided you know the URL. The images are in the PNG format (not ICO) and hence will render correctly in all browsers via the <img> tag.
The syntax for favicons is google.com/s2/favicons?domain=<www.abc.com>
For instance, if the site address is labnol.org, the URL of favicon image will be:
http://www.google.com/s2/favicons?domain=www.labnol.org
To see all this in action, go to your Google Profile page and check the URL of favicon image that is displayed next to your website link - see example.
Now that you know the basics, try this WordPress plugin I wrote to make it easier for you to integrate favicons in your blog comments. Here’s the internal code:
if (!empty($comment->comment_author_url)) {$url = preg_replace('/^http:\/\//', '', $comment->comment_author_url); if ($url != "") { $imgurl = "http://www.google.com/s2/favicons?domain=" . $url; echo '<img src="' . $imgurl . '" width="16" height="16" />'; }}
This gets slightly complex if you are on the Classic Template of old blogger since the authorURL is not directly available and you may require some JavaScript manipulation to get the URL from <$BlogCommentAuthor$>.
However in the new version of Blogger, you can get the URL of the commenter directly using the authorUrl Data Tag so the above technique can be ported to the new Blogger.
And if you have not added a favicon to your blog yet, check this guide on how to add favicons.
Find this article at: http://www.labnol.org/internet/get-favicon-image-of-websites-with-google/4404/
web: http://www.labnol.org/ email: amit@labnol.org



Reader Comments
I guess this is the same thing you have used in your favourite websites list images.
Written by Amit Bhawani on 09.04.08
Amit you’ve come up with a nice, simple Wordpress plugin that grabs the favicon from commenters’ websites and uses them instead of an avatar/gravatar. I presume it would be a simple matter to adapt it to use avatar if available and favicon if no avatar is found, that way 99% of commenters would be illustrated.
Written by David Bradley on 09.04.08
One thing you will have to watch out for are NSFW favicons…
Written by David Bradley on 09.04.08
Nice feature, but unfortunately this doesn’t work if the site has a Favicon defined by a LINK tag that’s somewhere other than /favicon.ico.
Written by Sean O on 09.04.08
Great Plugin, i think, i have to test it.
Written by Power on 09.04.08
Very nice plugin ^^
Written by Alyen on 09.05.08
Inspired by your post and my installing the plugin on my <a href=”http://www.sciencetext.com”>sciencetext.com site</a>, I’ve actually created an entirely new favicon for that site ;-)
Written by David Bradley on 09.05.08
great plugin!
Written by fisio on 09.06.08