Following snippet used(and works great) but generates a redirect chain :(.

If (function_excists('basicgravatar') 

 function basicgravatar ($avatar_defaults) {
   $myavatar = get_stylesheet_directory_uri() . '/images/gravatar.png'; //Child theme
   //$myavatar = get_bloginfo('template_directory') . '/images/gravatar.png';  //Main theme
   $avatar_defaults[$myavatar] = "New default avatar";
   return $avatar_defaults; }

add_filter( 'avatar_defaults', 'basicgravatar' );

Using GTmetrix which shows following:

Remove the following redirect chain if possible: http://0.gravatar.com/avatar/?d=http://oursite.com/media/wp-content/themes/our-child-theme/images/gravatar.png&s=40 and 2 more lines with almost identical msg.

Also this is shown as result after using code above:

The following resources have identical contents, but are served from different URLs. Serve these resources from a consistent URL to save 2 request(s) and 20.2KiB.

The more comments the more redirects.
(The quotes above show results after only two(2) comments and 1 author box, imagine 50 or more comments...)..how to solve this, without editing any core file.

Thanks in advance for time and effort.

2 Answers 2


This is essentially how gravatar service works.

Your code has no knowledge if particular email has gravatar associated with it. The only way would be to query gravatar API and store if there is gravatar available (and re-query for updates) for each email and resulting functionality will quickly snowball past just having that redirect there.

A little more practical tweak might be implementing lazy loading for gravatars, so they aren't loaded until visitor actually scrolls to them.


I use FV Gravatar Cache plugin which solves this problem by:

  • caching gravatars with WordPress cron job..
  • caching gravatars on comment submission
  • maintaining a single copy of the default gravatar instead of downloading it again and again for all the email addresses with no gravatar associated
  • I tried the plugin but it didn't solve the problem. Redirects are still in, would like to know how to disable that redirect to 0.gravatar.com Debug is showing also several Notices after installing this plugin, 1 in backend and 5 in frontend(I know, just notices ...still) But thank you for fast responding anyway! Note: will leave a msg here if found solution.
    – Charles
    Jun 28, 2012 at 0:26

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.