17.11.2010 in Home > Internet > WordPress by Namit Gupta

Add a New Default Avatar to WordPress [How to]

avatar
Image Credits: brtsergio/ Flickr.

When a reader comments on your blog, a small image is displayed next to his/her name. It’s either a local Avatar or a Global Avatar (Gravatar).

If you are confused between these two terms: avatar and Gravatar, Here is a brief differentiation between the both:

An avatar is an image associated with a community user to differentiate him/her with others, its like an identity mark. When you register on a community site you upload an image, which is displayed in your profile or at place where you perform any activity. This avatar is limited with only the website where you uploaded your image. For eg. Facebook, your Facebook profile picture is your avatar on Facebook, which is displayed where ever you do any activity on Facebook. And its limited to Facebook only, you cannot bring it to use anywhere else.

facebook-avatar

Web consists of million of websites, it is not possible for a user to again and again upload an image to each of the website where he takes part in any discussion. To solve this problem concept of a global avatar (Gravatar) was introduced.

Gravatar is a globally recognized avatar, you can go to gravatar.com and attach an image with your email id. Later whenever you will use that email id to take part in any discussion on Gravatar enabled website your Gravatar will be displayed.

Here is a step by step procedure on How to get a Gravatar.

Now back to the topic of this post, Adding a New Default Avatar to WordPress:

When you comment on any blog your Gravatar is displayed and if you do not have any Gravatar set on your email id a default avatar image, as specified by the blog administrator is displayed. WordPress has a limited set of default avatar images and has no option to assign a new image as default avatar. so in this post I’ll tell you a trick using which you can assign a new image of your choice as the default avatar to your WordPress installation.

Procedure to Add a New Default Avatar to your WordPress Blog

1. Upload the image which you would like to use as default avatar to your hosting space. Keep the size of image as 64×64 pixels. For eg, I made the following image a default avatar on this blog.

theitechblog's default avatar

2. Add the following code to your theme’s function.php file.

if ( !function_exists('fb_addgravatar') ) {
function fb_addgravatar( $avatar_defaults ) {
$myavatar = 'Image url';
$avatar_defaults[$myavatar] = 'Avatar name';
return $avatar_defaults;
}
add_filter( 'avatar_defaults', 'fb_addgravatar' );
}

Reach the file via ftp or you can also use the WordPress editor to edit the file, but I’ll recommend you to do it via ftp.

3. Replace the ‘Image url‘ with url of your image. and ‘Avatar name‘ with any name you would like to assign to the new avatar.

4. Save the changes.

You are done. Goto discussions page under setting tab in dashboard. Your new avatar now must be listed in the list.

New Default Avatar

If you experience any problem, feel free to put it in the comment box below.

  • Great tutorial.

    Thanks for this.

    I don’t have one. I need to create one.

    • Nihar, I wonder why you haven’t yet got a gravatar. Its good for personal branding. Do get one soon. Thanks for commenting. :-)

    • glad to see u got finally a gravtar!!!

      • Shashank, that is theitechblog’s default avatar. Which is been displayed if the commenter does not have a gravatar. This is the sole matter of this article. Go through the article once more. :-)

  • Nice tip bro :) Many users go for gravtar for choosing default avatar for all websites. I think we can use these easy steps in WP :)

    • Hey Vinay, I think you misunderstood something. This tutorial is to add a new image to your WordPress default avatar list, which will be displayed if commenter does not have any gravatar. Thanks for commenting mate. :-)

  • Thanks for this dude, now I can finally get rid of the dull WP standard avatar.

    • Hey Andy, thanks for your comment. You can replace the default logo with something related to your brand for eg. your brand logo which will help you in branding.

  • Really awesome. I think there are few themes which have this feature pre installed. Anyway thanks for sharing.

  • Implemented it.. thanks Namit. :)

  • Worked for me. Thanks for the help.