WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question

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.

share|improve this answer

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
share|improve this answer
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 '12 at 0:26

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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