How to use Gravatar image as WordPress favicon?

How to use Gravatar image as WordPress favicon?

Gravatar stands for Globally Recognized Avatar. It is globally recognized because millions of people and websites use them. To know more about Gravatar, you can visit https://en.gravatar.com.

To use Gravatar image as favicon on your WordPress site, add the following code in your theme’s functions.php file.

// Add the following code in theme's functions.php file to use Gravatar image as favicon (16x16 favicon.ico)
function dcg_gravatar_favicon() {
    // Replace email here
    $GetEmailHash = md5(strtolower(trim('me@dipakgajjar.com')));
?>

<link rel="shortcut icon" href="<?php echo 'http://www.gravatar.com/avatar/' . $GetEmailHash . '?s=16;'; ?>" type="image/x-icon" />

<?php
}
add_action('wp_head', 'dcg_gravatar_favicon');