Custom Gravatar not working

I’m trying to upload a custom Gravatar to WordPress, however something is breaking the image link and I’m not sure how to fix it.

add_filter( 'avatar_defaults', 'new_default_avatar' );

function new_default_avatar ( $avatar_defaults ) {
    //Set the URL where the image file for your avatar is located
    $new_avatar_url = get_bloginfo( 'template_directory' ) . '/img/icons/avatar.jpg';
    //Set the text that will appear to the right of your avatar in Settings>>Discussion
    $avatar_defaults[$new_avatar_url] = 'New Default Gravatar';
    return $avatar_defaults;

The code works, because I get a radio button with the option to add the Gravatar. The only thing that is broken is the actual image.

When I right click on the image I get this URL:

I’m not sure where is coming from, or what it’s doing. When I remove that and do


I can see the Gravatar image.

When I googled this, I saw a lot of people have this problem because of the Jetpack and Photon plugins, but I do not have any plugins installed.

Solutions Collecting From Web of "Custom Gravatar not working"

I think the problem is simply that your default avatar isn’t publicly available.

Try for example

instead of

Notice that the default gravatar is served via http{|s}://i{0,1,2}

From the docs:

When you include a default image, Gravatar will automatically serve up that
image if there is no image associated with the requested email hash. There are a > few conditions which must be met for default image URL:

  • MUST be publicly available (e.g. cannot be on an intranet, on a local
    development machine, behind HTTP Auth or some other firewall etc). Default
    images are passed through a security scan to avoid malicious content.
  • MUST be accessible via HTTP or HTTPS on the standard ports, 80 and 443,
  • MUST have a recognizable image extension (jpg, jpeg, gif, png)
  • MUST NOT include a querystring (if it does, it will be ignored)

This is because of Photon addon you enabled in JetPack plugin. That’s why your image URLs will be like…


You will get any of these three URLs. It’s WordPress’s free CDN services. Which is great.

The problem is that you are trying it on localhost that’s why it’s not working. Because WordPress CDN or any other CDN can not pull images from localhost. You should try it on online server. Just disable photon and everything will be fine 🙂

Word of advice, never turn on CDN services on localhost. You will get into errors.

EDIT: By default it should have something like…

But in your case it’s using which must be caused by a plugin or you added some code in functions.php.

Did you added code in functions.php to return all images from This must also be a case.