Recently, I am working on getting my custom default avatar for WordPress Theme, however, the situation is, I am working in a local environment, and keeps on getting i2.wp.com as a prefix on my image URL.
For example, if I have:
http://localhost/path_to_my_image/avatar.jpg
WordPress will immediately add i2.wp.com, which I do not have any idea why, I have:
http://i2.wp.com/localhost/path_to_my_image/avatar.jpg
As part of isolation, I tried to disable all plugins to ensure no unwanted behavior on my working environment, and still failed. In fact, no Jetpack plugin on my working environment.
I almost give up and took a quick break for 5 mins.
Thanks to wordpress.stackexchange.com issue lie on my image that is not accessible online, which I have no idea this will matter
Here are the details below:
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 Author 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, respectively.
MUST have a recognizable image extension (jpg, jpeg, gif, png)Source https://en.gravatar.com/site/implement/images/
MUST NOT include aquerystring (if it does, it will be ignored)
Finally, I made it work. The test image provided was:
https://upload.wikimedia.org/wikipedia/en/b/b0/Avatar-Teaser-Poster.jpg
Complete code:
function default_gravatar ($avatar_defaults) {
$avatar = 'https://upload.wikimedia.org/wikipedia/en/b/b0/Avatar-Teaser-Poster.jpg';
$avatar_defaults[$avatar] = "Default Gravatar";
return $avatar_defaults;
}
add_filter('avatar_defaults', 'default_gravatar ' );
I hope this will help you out in someways.
Unfortunately, that doesn’t help anymore.
By default, it is now redirected via * .gravatar.com,
but your hack just changes it to use * .wp.com instead.
OK, it’s a bit better, but I would really like it without any diversion.
I would like it if there wasn’t any external tracking at all.
I tried it, but sadly it’s not working anymore.