Add Image to Default Avatar List in WordPress

[ad_1]

When readers comment on your blog, WordPress uses the Gravatar platform to display a picture of the commenter next to his or her comment. If a commenter doesn’t have a Gravatar, or their email address isn’t associated with one, then WordPress displays the Mystery Man Gravatar as the default avatar in comments. WordPress also offers a couple of more generic avatars to choose from as your default avatar. Although it’s nice but sometimes you want to use your own unique custom avatar or may be your website logo for brand recognition. You can also read about how to display circular shape avatars in comments on your website.

In this article we will show you how to add your own image to default avatar list in WordPress, so you can select it as your default avatar for comment section. For avatar image, just make sure that image has equal width and height aka square-shaped and should not be large in size. A 100×100 pixel image is more than enough to be used as an avatar in most cases.

Upload avatar to you theme images folder and paste this code snippet to your functions.php file. Don’t forget to change image name and title before pasting this code in your theme.

// add image to default avatar list in wordpress
function wcs_add_image_default_avatars( $defaults ) {
    $new = get_stylesheet_directory_uri() . '/images/default-avatar.jpg';
    $defaults[$new] = "WPCodeSnippet";
    return $defaults;
}
add_filter( 'avatar_defaults', 'wcs_add_image_default_avatars' );
[ad_2]

Leave a Reply

Random Post Selection ::

Recent Posts

Unlock Unlimited Downloads