Take the 2-minute tour ×
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 gravatar.com images on every comment. Where my custom avatars are used, the scr result still includes a hashed link to gravatar.com 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: http://1.gravatar.com/avatar/9cf9ecff0dd6eed9a1ea0948c61dc3c2?s=44&d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D44&r=G

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 gravatar.com, their Twitter profile image, or (if left unchecked) if default, locally-hosted images apply. If the checkbox for gravatar.com 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 gravatar.com 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 gravatar.com. –  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
add comment

1 Answer

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
add comment

Your Answer

 
discard

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