Sign up ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Problem: I am using custom avatars for registered users and my own locally-hosted image as the default gravatar. I want to stop WordPress making HTTP requests to check for images on every comment. Where my custom avatars are used, the scr result still includes a hashed link to with a redirect appended to the scr URI back to my own image.

Even without using a custom default avatar, there are two HTTP requests sent out. For default avatars this looks like:

I neither want, nor need, this kind of bloat in my pages.

Goal: What I want to do is to override the gravatars function in pluggable.php so that it only runs when a checkbox is checked. I have added a form field to my comments form so commenters can specify if they want to use their gravatar image from, their Twitter profile image, or (if left unchecked) if default, locally-hosted images apply. If the checkbox for avatars isn't selected then it shouldn't run at all.

I'm stuck on how to tie the get_avatar function to run only if the checkbox input returns true.

share|improve this question
I'm interested in this too. WordPress does make HTTP requests when it checks if the email address matches a user. I use custom avatars as well and hate the way the avatar URL is output. Is there a way to override the gravatar to get a clean URI to custom avatars? At the moment the image is pulled by a redirect back from – Elpie Jan 27 '11 at 13:49
It really doesn't make requests, or at least not in the way that I can find in any relevant code. There is no actual need to make any requests per gravatar mechanics, unless I am missing something? As per my answer you can use get_avatar hook to change URL. If you provide some specifics on what you need done I can come up with example code (if you need it). – Rarst Jan 27 '11 at 14:13

1 Answer 1

WordPress never makes any HTTP requests for gravatars, it just generates URLs to them.

You don't really need to override function completely. You can filter get_avatar hook and return different URL if email matches user with custom avatar set.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.