Is it possible for a WordPress site to display the users default Gravatar image (of chosen set, eg Retro, Identicon, etc), rather than the users uploaded avatar? As in, all user avatars next to comments would be a generated ‘Retro’ picture, regardless of whether they had a custom avatar at Gravatar or not.
Screenshot of the settings in question:
Since these default avatars are generated based on the email of the user, I was wondering if it is still possible to generate them, or have Gravatar return these default generated avatars rather than the users custom avatar.
Yeah it is possible.
Just add a function to the
get_avatar
hookFound you can create the address manually to return the image from Gravatar, and pass in parameters to force default and theme. Combined this in part with @Sudar’s answer, as well as the code from
pluggable.php
as the admin page will grab the ID not email from$id_or_email
, so a check needed to be added so the admin page shows the correct avatars.Read more:
http://en.gravatar.com/site/implement/hash/
http://en.gravatar.com/site/implement/images/
Nowadays it’s much easier thanks to
get_avatar_data()
which is being called byget_avatar()
: