Post Pic

How to use your Gravatar as a favicon on your WordPress blog

Do you want to be able to use your gravatar as a favicon on your WordPress blog? That’s pretty easy to achieve with this trick. Enjoy!

First, edit the following function by adding your email adress on line 3, then paste it on your functions.php file.

function GravatarAsFavicon() {
	//We need to establish the hashed value of your email address
	$GetTheHash = md5(strtolower(trim('you@yourdomain.com')));
	echo 'http://www.gravatar.com/avatar/' . $GetTheHash . '?s=16';
}

Once done, open the header.php file of your theme and paste this:

<link rel="shortcut icon" href="<?php GravatarAsFavicon(); ?>" />
<link rel="apple-touch-icon" href="<?php GravatarAsFavicon(); ?>">

Thanks to Adam Whitcroft for the cool tip!

4 Responses

Jul 26 2012 17:12

Very easy to implement, thanks a lot Adam. :)

Aug 11 2012 02:11

Thanks thats just a small job. For some reason the function GravatarAsFavicon() { part once copied to clipboard changed the () but i missed that , works!

NIce blog to!

Nov 07 2012 01:34

The problem I have is when reducing my Gravatar to 16 by 16 pixels I get a fuzzy mess which doesn’t look good. Is there any way I could sharpen the image before using it as my favicon? I’m good with Photoshop but not that good.

Dec 17 2012 15:46

if (!function_exists(‘insert_favicon’)) {
(insert_favicon);
}
function insert_favicon() {
echo ”;
}
add_action(‘wp_head’,'insert_favicon’, 1);

Trackbacks:

Leave a Comment

* Name, Email, Comment are Required

WP Theme of the week

Sponsored Likebox