Reputation: 393
I have done this so many times but for some reason it doesn't work today!
This is the function used for adding a default gravatar:
//***Custom Gravatar**/
add_filter( 'avatar_defaults', 'custom_gravatar' );
function custom_gravatar ($avatar_defaults) {
$myavatar = get_stylesheet_directory_uri() . '/images/gravatar.png';
print_r($myavatar);
$avatar_defaults[$myavatar] = "Custom Gravatar";
return $avatar_defaults;
}
In Settings > Discussion, the title "Custom Gravatar" shows, but no image. No image on the front-end either.
print_r($myavatar);
shows the correct URL.
The URL shows the correct image.
The image src on the front-end outputs like this:
http://0.gravatar.com/avatar/0d2ef201aafaf4849d2fd2bccaba6ea4?s=60&d=http%3A%2F%2Fstaging.cashmoneylife.com%2Fwp-content%2Fthemes%2Fgenesis-sample-master%2Fimages%2Fgravatar.png&r=g
Am I overlooking something really simple?
Upvotes: 1
Views: 387
Reputation: 2155
Found this post which states (quoting the Gravatar documents):
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, respectively.
- MUST have a recognizable image extension (jpg, jpeg, gif, png)
- MUST NOT include a querystring (if it does, it will be ignored)
Any chance you are developing locally???
Upvotes: 1