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.

I was wondering if the default image generated for a user in the comment section is "set" somewhere in the WordPress backend. If so, I'm not sure where this setting is. Please see this image to see what i'm referring to:

screenshot of images in comment section

The user Jimmy Jacob doesn't have an image yet the commentor Catherine does. Without installing plugins, is there a native WordPress setting which would let me upload a default image to use for this?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

Here's a function you can put in your theme's functions.php file to force your own default avatar. Update the $myavatar line to point to your image path/name:

// Adds a new default avatar to the list in WordPress admin
add_filter( 'avatar_defaults', 'mytheme_addgravatar' );
function mytheme_addgravatar( $avatar_defaults ) {
    $myavatar = get_bloginfo('stylesheet_directory') . '/images/my-avatar.gif';
    $avatar_defaults[$myavatar] = 'New Default Gravatar';
    return $avatar_defaults;
}

Once you've added this function, your new avatar will appear in the list in the WP control panel in the "Settings > Discussion" area. Select it and save. Now if visitors don't have their own Gravatar your new avatar will appear instead.

(If you're just looking for how to get your own Gravatar, which will show up on most WordPress blogs/sites in the comments section, go to http://gravatar.com and sign up for a free account.)

Hope this helps - best of luck!

share|improve this answer
    
Great thanks, that was excellent. –  21zna9 Dec 6 '11 at 3:25

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.