WordPress Comments Plugin – Cache and Customize Your Gravatars

Shiba Gravatar is now called Shiba Comments because we are broadening the plugin to include other comment related capabilities.

The Shiba Comments Plugin allows you to –

  • Cache gravatar images locally on your server as well as use your own set of gravatar images.
  • Move comments between posts.
  • Parent a comment to any other comment. Note – make sure not to create comment loops while doing this.
  • Change the comment IP.

[Most recent Shiba Comments Plugin updates]

December, 2015
Tested on WordPress 4.4. No changes needed.

August, 2015
Tested on WordPress 4.3. No changes needed.

1. Cache WordPress gravatar images locally on your server.

The gravatar.com site may sometimes get overly busy and as a result, it may significantly slow-down the load time of your WordPress posts and pages. This is especially true if you have many comments on one page.

Note that the slow-down will occur even if your comments may not have gravatar images registered to them. In this case, a call still has to be made to the gravatar.com site which then sends back a generated gravatar image (e.g. Wavatar, Monsters) or a fixed default image (e.g. Mystery Man).

The Shiba Comments Plugin will cache all of the gravatar images locally on your server.

When your article gets viewed, the author images can be retrieved quickly from your local cache without having to visit the gravatar.com site.

Unlike other gravatar caching plugins, the Shiba plugin will only create and update the gravatar cache when a new comment gets submitted, or when you explicitly tell it to rebuild the cache.

The disadvantage – You need to manually instruct the system to update its cache.

The advantage – The plugin is much simpler and you will not need to schedule any cron jobs on your server.

After you install the Shiba Comments plugin, go to Settings >> Discussion to assign the gravatar type of your choice. Note that there is a new gravatar setting called Shiba Gravatar. Select Shiba Gravatar if you want to use your own custom gravatars for non-registered comment authors.

Next, go to Comments >> Cache Gravatars to create an initial cache for all your existing comments.

There are three options in the Cache Gravatars menu –

  • Cache Gravatars – Extracts user information from all current comments, and use that email list to expand the gravatar database. Use Cache Gravatars when you first install the plugin, and need to populate your gravatar cache from scratch.
  • Update Cache – Updates existing user entries within the gravatar database. Use Update Cache if your cache has already been populated, and you only want to check for new registered gravatar images.
  • Clear Cache – Clears your gravatar cache. If your cache is corrupted, you can rebuild it by doing Clear Cache and then Cache Gravatars.

Note – When caching generated gravatars, make sure to always Clear Cache first, then Cache Gravatars.

I have observed that most people do not change their gravatar images very frequently. As a result, it is unnecessary to constantly update the gravatar cache, and place extra load on your web server.

I created this plugin because personally, I prefer to be in control of when the gravatar cache gets updated – which need not be very often at all.

2. Custom Gravatar Images

Custom gravatar images come into play when the comment author does not enter in an email address or when the email address is not linked to a gravatar account.

When this occurs, you can either instruct your WordPress system to return a fixed default image, or generate a custom image from one of the predefined custom image sets (e.g. Wavatar, Monsters). Currently, you can personalize the fixed default gravatar image, but it is not possible to use your own custom image set.

The Shiba Comments plugin allows you to specify your own set of custom gravatars. All you have to do is attach your set of custom images to a post, page, or gallery using the standard WordPress Media Library. Then, assign that gallery to the Gravatar Plugin in the Comments >> Cache Gravatar page.

If no gallery is assigned, the plugin will use its own set of custom gravatar images (shown below).

Shiba Comments Future Additions

  • Add update scheduling support (using wp_cron) in addition to manual update capability.

Shiba Comments Plugin Updates

Shiba Comments 1.3.1

September 14th, 2014

  • Updated anonymous nonce creation function for the background cache gravatar process.
  • Tested on WordPress 4.0.

Shiba Comments 1.3

April 20th, 2014

  • Updated plugin directory and url to use functions instead of constants.
  • Added metaboxes to the Cache Gravatar page.
  • Updated the Cache Gravatar page so that it uses standard WordPress forms, settings, and messages.
  • Tested on WordPress 3.9.

Shiba Comments 1.2

Jan 20th, 2013

  • Streamlined caching process so that it makes fewer database calls.
  • Added security nonce check for caching process.
  • Added ability to stop caching process.

Shiba Comments 1.1.3

December 13th, 2012

  • Updated for WordPress 3.5.
  • Added AJAX calls for expanded quick edit functions.
  • Check for loops when assigning comment parent.
  • Divide comment avatar processing into segments so as to limit memory usage requirements. We can set the segment size in the Cache Gravatar page. A higher group size means higher memory requirements and vice versa.
  • New Emoti-Guy default avatar images!

Shiba Comments 1.0

Aug 3rd, 2012

  • Updated for WordPress 3.4.
  • Added ability to change comment post, comment parent, and comment IP from the Edit Comment and Quick Edit menus.
  • Upgraded gravatar cache to use user_id (in addition to comment email, IP, and author) while caching avatar images.

WordPress Gravatar Plugin 1.4

Jan 10th, 2011

  • Updated for WordPress 3.1.
  • Plugin will now cache ALL gravatar images including generated gravatar images. Only cache generated images if your site has a manageable number of comment authors. Otherwise, it is more efficient to use your own default set of gravatar images.
  • Gravatar images are now cached according to your gravatar settings in Settings >> Discussion.

WordPress Gravatar Plugin 1.3

June 29th, 2010

  • Attach a post, page, or gallery as your Custom Gravatar gallery. This allows you to use your own set of custom images for comment authors that are not registered with gravatar.com.
  • Easily switch to different sets of custom gravatar images by attaching the plugin to different posts or galleries.
  • Easily switch between using standard WordPress gravatars and your custom gravatars through the standard gravatar setting under Settings >> Discussion.
  • Plugin no longer uses proc_open to run the caching process. It should now work across most hosting platforms.

WordPress Gravatar Plugin 1.2

  • Plugin is updated for WordPress 3.0. It was tested on both 2.9 and 3.0.
  • Plugin no longer uses proc_open to run the caching process. It should now work across most hosting platforms.
  • Custom gravatar images will now appear in the WordPress administration menus.
  • Added an Update Cache button for updating existing gravatar entries in the cache.

WordPress Gravatar Plugin 1.0

  • Provides manual gravatar caching and custom gravatar image sets.

Related Articles


  1. Brandon says

    I am apparently illiterate when it comes to using plug-ins. I need some help changing my avatar to a personal picture for our blogging purposes. Can someone please Help? email me please.

  2. says

    Warning: Missing argument 1 for Shiba_Gravatar_Cache::get_custom_avatar(), called in /../blog/wp-content/plugins/shiba-comments/shiba-gravatar-settings.php on line 36 and defined in /../blog/wp-content/plugins/shiba-comments/shiba-gravatar-cache.php on line 166

    any ideas why I see this on the DISCUSSION page wp 3.4.2 in the avatar section??

  3. banesto says

    Thanks for the work being done, but:
    1. title should not include word Gravatar as it has nothing to do with it – plugin displays local avatars for users without gravatars. I was looking for gravatar caching plugin and Your plugin name implies it does it, but it’s not.
    2. it gets a lot of errors when folder permissions are not set correctly and in readme file there are no mentioning about folder permissions.

    • ShibaShake says

      Dear Banesto,
      1. The plugin caches gravatars locally as well as displays local avatars.
      2. Thanks for letting me know. Which folders result in what errors? If you give me some details I can include it in the documentation.

    • ShibaShake says

      That is an awesome idea! It would simplify the interface significantly, and make it easy to swap different custom images in and out.

      I will definitely start working on this next.

  4. says

    maybe I got it ๐Ÿ˜‰ I try it on a very new domain with only 4 comments.

    I delete all your images and now your plugin shows my default gravatar and my admin-gravatar correct.

    No I’ll try it on another domain – there are more than 10thousand comments.

    I will give it a try ๐Ÿ˜‰ and I’ll come back for feedback– if it does its job it would be great:-)

    • ShibaShake says

      Hello Monika,
      If you have replaced the images, then make sure to do “Clear Cache” and then “Cache Gravatars” again to link the emails to the new images.

      Let me know if you run into any issues.

  5. ShibaShake says

    Hi Lynsey,

    This time all avatars have been replaced with the uploaded avatars until I went through and edited by simply re-saving the comments.

    Yikes – you really shouldn’t have to do that.

    In a situation like this, just try doing clear cache and build cache. This will rebuild the cache from the comments database.

    I also discovered a few days ago that proc_open can stop working due to certain server errors. This happened with one of my servers last week and I was getting the same kind of behavior as you did the first time.

    In the next release I will work on creating a cache option that does not use proc_open. I will also look into having the custom gravatars appear on admin screens, and integrate a custom gravatar interface into the current avatar control panel.

    Thanks for letting me know all the issues you encountered with the plugin. It helps a lot with future improvements.

  6. says

    Just done another install, this time at http://freshnewday.net. Again, works, but not in an expected way. This time all avatars have been replaced with the uploaded avatars until I went through and edited by simply re-saving the comments. On each edit/save those comments with ‘official’ gravatars were restored. Working, but working in unexpected ways.

  7. ShibaShake says

    Hello Lynsey,

    That is indeed very strange. I just downloaded Deep Silent and tested it, and there does not seem to be a theme issue.

    There could be several possibilities –

    It could be that the plugin is unable to start a new process to do the caching operations. I am no server expert, so I can’t say for sure what is the root cause. My best guesses would be –
    1. The environment is a windows environment, which may have issues with the PHP proc_open command.
    2. There is some security protection server side that blocks this command.
    However, the custom gravatar images should still show up even if you can’t run the cache.

    It could also be a plugin conflict issue – although that does not seem very likely for this particular plugin.

    If you install the plugin from scratch but *do not* run the cache – what do you get as the gravatar images? What do you get if you add in a new comment as an anonymous user? What do you get if you change the gravatar to Wavatar or Identicon? What do you get if you turn off other plugins? What do you get if you use the default Kubrick or classic themes?

    • says

      It works! It works! ๐Ÿ™‚ A bit not quite as expected, but it’s the end result I’m looking for. The big hint to get things jump started was to change to use the kubrick theme. I deleted everything from the server end and reinstalled the plugin, including running the build cache that suddenly worked. The avatar setting is Mystery Man (MM). My test users still show up inside WP as MM, but outside on the comments as the default ladies, nice work, by the way. I move the ladies off into a folder, upload my avatar images, clear the cache and rebuild. Bingo, we have a winner. Test users inside WP still MM, outside they’re my images. Yay! I change the theme to my desired theme, still works. Move from test site (not windows, btw) and do the install at the destination site (http://cpcanz.org.nz) and yes, I do believe we have a winner.

      The approach, I believe for others trying to make this work, is to do very little. It appears to work with the default images. Once you’re there, move them out and upload your images to that folder. Don’t use any other folders for images, I believe there’s some confusion there – the plugin might be trying to draw from two sources and this somehow confuses the result. I mention this because MiniMeta Widget plugin is set to show my gravatar while I’m logged in – I noticed suddenly my avatar vanished and was replaced by my one of images. Inside WP, in the users tab, my avatar is as it should be. I suspect there’s some sort of twitchy issue between the plugins. I’m not fussed, it’s working fine so far, any issues (if any) will get mopped up in the next version.

      Thanks, Shibashake, it might not work quite the way I expected/imagined; but it works the way I wanted. Cheers and thanks again.

  8. says

    I’m using Wp2.9.2 on a test site and the plugin is steadfastly ignored. I have loaded duplicate sets of images to wp-content/images/gravatar/, plugin/images, and even loaded a set of images directly to plugin/cache/

    Nothing. No changes. I clear the cache, and then re-cache. The message: Caching Gravatars No results yet. remains unchanged. I’ve deactivated and reactivated the plugin. The standard images supplied don’t load.

    It’s as though the plugin simply doesn’t exist – other than the ‘Cache Gravatar’ showing up in the comments tab nothing happens.

    The avatar setting is for Mystery Man. Should this be something else? Am I missing something somewhere else?

    • says

      As a further note, the theme I am using is Deep Silent. I wondered if the issue was because of some conflict with functions.php. I deleted all of the gravatar related functions, and reloaded. No changes. ๐Ÿ™

  9. ShibaShake says

    The one issue I see is that, if people comment more than once in a post, their gravatars arenโ€™t the same each time.

    Hmmm, that is strange. It should be the same once it is cached. If you purge the cache, then a different gravatar will get assigned, but they should be the same for the same email address, or if one does not exist, then IP.

    For example, your gravatar is the same for all your comments.

    Try downloading the latest zip and see if this issue goes away. Sometimes I forget to sync up the zip files with the latest versions, and I have made several recent changes to the gravatar plugin.

    Is there a way to increase the display size of the gravatars? Mine were a bit bigger before I activated the plug-in. I tried changing the โ€œ42โ€ณ size in the plugin to โ€œ72โ€ณ but that didnโ€™t seem to affect anything, even after I deleted the cache. Any thoughts?

    The gravatar image size should be something that is solely controlled by your theme – most likely in the comments.php. Look for the get_gravatar function and the second argument is the image size.

    The ’42’ size in the plugin just sizes the gravatar images that appear in the cache log and does not affect your blog gravatars. The plugin caches gravatars at 80×80 which is the default.

    I tested changing the size of the gravatars on a few themes and it seems to work. Let me know if you continue to have issues with this, and I can try looking into the theme you are using.

  10. Trevor says

    Hey there,
    Thanks for your help. I really appreciate it. I’m glad my feedback is helpful to you too.

    I’ve got it working and my custom gravatars are appearing. The one issue I see is that, if people comment more than once in a post, their gravatars aren’t the same each time.

    Is there a way to increase the display size of the gravatars? Mine were a bit bigger before I activated the plug-in. I tried changing the “42” size in the plugin to “72” but that didn’t seem to affect anything, even after I deleted the cache. Any thoughts?

    Thanks again!

  11. ShibaShake says

    If there is no email present, the plugin will use IP address to assign gravatars, i.e. all blank email comments from the same IP address will get the same gravatar image.

  12. ShibaShake says

    I looked at the gravatar randomize algorithm, and there were some flaws in it. I have come up with a better way to randomize the images so it should work better now.

    The zip has been updated, so just install, clear cache, and regenerate avatars.

    After I activate the plugin, I go to the Discussion page but thereโ€™s no option to select my own Gravatar set, just the usual options.

    Currently, the plugin will always try to use custom avatars when it is activated. It will first look in the wp-content/images/gravatar directory then in the plugin/images directory. If it cannot find images in these directories, it will revert back to using whatever is set in WordPress.

    In the next release I will work on adding the ability to include multiple different sets of custom avatars right from the gravatar menu.

    Thanks for helping me make this into a better plugin. Please continue to report problems and features you would like to see.

  13. Trevor says

    Thanks for that fix. Unfortunately, it’s still not working right for me.

    I installed the plugin and replaced your custom Gravatars and have added the same 20 images to wp-content/images/gravatar/. After I activate the plugin, I go to the Discussion page but there’s no option to select my own Gravatar set, just the usual options. When I look on my blog, one of my custom images is appearing for all of the Gravatars, regardless of which Gravatar option I chose under Discussion. Unfortunately, it’s the same image for everybody.

    I don’t know if this is of any use but, the first time I tried it, the image was Face20.jpg. I deactivated everything and deleted that image (from both folders). I tried again and this time, it only used Face02.jpg. I deactivated everything and deleted that file. The next time I tried activating it, I only got blank gravatars. I’ve tried changing the Gravatar setting under Discussion to different sets but still get the same result.

    Any thoughts?

  14. ShibaShake says

    Thanks for reporting the bug Trevor. I have fixed it, so just download the zip and re-run Cache Gravatars.

    Please let me know if you run into any more problems. Thanks.

  15. Trevor says

    Hi there,
    I was really happy to find your plugin as I’ve wanted to customize my generic gravitars for some time. The aliens and little creatures just don’t cut it. ๐Ÿ˜‰

    Anyway, I’ve tried to activate the plugin but I get a php error:

    Plugin could not be activated because it triggered a fatal error.
    Fatal error: Call to undefined function get_images() in /mnt/stor1-wc2-dfw1/471032/www.mysitename.com/web/content/wp-content/plugins/shiba-gravatar/shiba-gravatar.php on line 308

    I have the original images in the folder for right now and am using WP 2.92.

    Any thoughts on what I’m doing wrong?
    Thanks for any suggestions you can share.

Leave a Reply

Your email address will not be published.