Trying to fix a plugin (https://wordpress.org/plugins/gravatarlocalcache/ not mine) which broke on the 4.2 update.

The plugin makes a locally cached version of Gravatar.com avatars.

Plugin hasn't been updated recently (current version 1.1.2) and looks abandoned, so though I've posted in the WordPress support forum, doubt I'll get a fix from the plugin author.

Tracked the issue down to WordPress 4.2 (works in 4.1), but don't know why.

The plugin makes a local copy of Gravatar.com avatar images using

$_tmp = download_url(str_replace(utf8_encode('&'), '&', $_imageurl));

line 211

Github code at https://github.com/oikeusministerio/blogi.otakantaa.fi/blob/master/wp-content/plugins/gravatarlocalcache/GravatarLocalCache.php

With avatars that have a Gravatar account (registered email addresses) the correct image is saved locally. For the randomly generated avatars the default Gravatar logo (blue avatar with a G in the middle) is saved instead with the correct filename.

So for commenters who have a Gravatar account their profile images are saved locally, for generated avatars the correct filename is saved, but it's a copy of the G logo.

Avatar changes in 4.2 is the addition of responsive images using the scrset attribute which is a copy of the Gravatar URL ending in x2. I don't see how this would stop the correct image being saved for the randomly generated images only.



  • 1
    Is there any debugging information about what the values and results of those variables are? This plugin seems a little redundant since the browser can just request ( and cache locally ) gravatars
    – Tom J Nowell
    May 3, 2015 at 16:49
  • Exactly as @TomJNowell said. Why lose all that Gravatar has to offer? (parallel requests, CDN, optimized caching, bandwidth saving yada yada yada) May 3, 2015 at 16:58
  • I use caching for performance reasons. Explained at stallion-theme.co.uk/wordpress-gravatars gravatar.com doesn't optimize it's images and has the browser cache set too short (5 minutes) which effectively means the images aren't cached by a browser: caching an image for only 5 minutes means most users will have to download again every visit. So by using gravatar.com for avatar images the Google PageSpeed Insight Tool throws out a bunch of warnings, since Google considers page speed important SEO wise, not fixing them could have a negative impact on Google rankings.
    – David Law
    May 3, 2015 at 19:39
  • The plugin has one PHP warning related to unlink: tries to unlink the tmp file when it's already been unlinked, I think the error trips when the image is downloaded from gravatar.com. Been throwing this error out since day one, so don't think it's related to the 4.2 issue.
    – David Law
    May 3, 2015 at 19:39


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.