Gravatar is slowing my website and I want to host mystery man on my main server. So this is my normal gravatar mystery man

<img class="avatar avatar-68 avatar-default" width="68" height="68" alt="avatar" style="width: 68px; height: 68px;" src="http://1.gravatar.com/avatar/b759acf051d7e8b32049b6527ac13485?s=68&d=http%3A%2F%2Fwww.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D68&r=G"></img>

And I want to host it on my server, so I tried to use this php code

function my_own_gravatar( $avatar_defaults ) {  
    $myavatar = get_bloginfo('template_directory') . '/design/img/m.png';  
    $avatar_defaults[$myavatar] = 'DEFAULT SPEED';  
    return $avatar_defaults;  
add_filter( 'avatar_defaults', 'my_own_gravatar' ); 

But then there is still gravatar and redirect that is slowing loading time

<img src="http://0.gravatar.com/avatar/470ba3844a4ca24a9a125e198a424027?s=68&amp;d=http%3A%2F%2Fwww.my-website.com%2Fwp-content%2Fthemes%2Fdirectory%2Fdesign%2Fimg%2Fm.png&amp;r=G" class="avatar avatar-68 avatar-default" height="68" width="68" style="width: 68px; height: 68px;" alt="avatar">

F***ing gravatar - Can you please help me ?

2 Answers 2


Your code actually works, it is just that you can't do what you want.

The way gravatar works is by serving the image if it has one and redirecting to the supplied default if it doesn't, so even if the default is on your server you still can't avoid the redirect.

And gravatar really makes your site load faster

  1. makes your server less loaded
  2. enables the browser to make one more simultaneous request to your site to fetch something else (browsers are limited to 6 simultaneous request per domain)
  3. gravatar's mystery man is probably at a CDN and served from a place much "closer" to your user than your server
  4. gravatar's mystery man is probably already in the browser cache and no request is done to fetch it, your mystery man is unlikely to be there.
  • But there are still redirects, that are slowing website. It's proven ..anyway developers.google.com/speed/pagespeed/insights check it.
    – Chymmi
    Feb 10, 2013 at 17:50
  • having no redirects is better then having redirects, but when you use a third party service you have only limited control on the redirects. And sometime, like in your case, the alternative to a redirect is worse then a redirect. Feb 10, 2013 at 19:56

Here is a code snippet I have used multiple times. It allows you to set a default user image, selectable in Dashboard >> Settings >> Discussion >> Avatar

I'm not sure where it came from, so I cannot properly credit it, however.

//Add a Default "Gravatar" to Options

if ( !function_exists('fb_addgravatar') ) {
function fb_addgravatar( $avatar_defaults ) { 
    $myavatar = get_bloginfo('template_directory') . '/images/default_user.png';
    $avatar_defaults[$myavatar] = 'My Website Default Image';
    return $avatar_defaults;
add_filter( 'avatar_defaults', 'fb_addgravatar' );

Change image file name and path. Change the name of the image to display in settings.

  • 1
    Unless, there's another FB out there, the prefix fb_ is from Frank Bueltge.
    – brasofilo
    Feb 10, 2013 at 16:31
  • I already have this (if you read my post at the beginning) - but there is still gravatar redirect and slow down my website.
    – Chymmi
    Feb 10, 2013 at 18:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.