How to change the default gravatar picture of your WordPress blog

Have you ever thought of changing the default gravatar of your blog and giving your blog a personal look? One of the things recommended by me is to change the default gravatar of your blog to get a personal and unique look.

I hope that almost all the commentators of your blog do not have a gravatar. Today, I will show you how to change the default gravatar image of your blog.

gravatar

How to change the default WordPress Gravatar picture

  • Get the image which you want to use. It should be around 82×82 in pixels. This will clash between the owner’s comment and faceless visiting commentators.
  • You can use Smush It! To reduce the size of the picture you will use. You should do so that it should not have much load, and if your pictures will have much load, then the loading speed of your blog will increase. All you need to do is to go to Smushit.com and the picture which you wanna compress.
  • Upload the compressed image using the ftp app or with the cPanel of your website. Commonly people use ftp apps like Filezilla and fireftp which is the addon of Firefox and believe me, they all are very easy to use.
  • Now the new gravatar for your blog is ready. Then, you have to go to the gravatar list in the discussion part of the settings sections of your blog’s admin panel. Mark it as default. Just copy the code below to the functions.php file. I will tell you how and where to paste the code.
add_filter( 'avatar_defaults', 'newgravatar' );

function newgravatar ($avatar_defaults) {
$myavatar = get_bloginfo('template_directory') . '/images/gravatarfilename.jpg';
$avatar_defaults[$myavatar] = "GravatarName";
return $avatar_defaults;
}

Where is the function file?

  • Go to ‘Appearance’
  • There you will see ‘Editor

Note: Make sure that you select the theme which you are using currently on your WordPress blog.

Where to paste the code?

  • Click on function.php file
  • Copy the php code given above and pasted it on the bottom of the functions file
  • To save the changes, click on ‘Update file.

Make this code to work

There are 2 things which are necessary to make this code to work.

  1. Change the name of the file from gravatarfilename.jpg to the name of the file you have uploaded on your blog and you wanna keep as your blog’s gravatar picture.
  2. Change the $avatar_defaults[$myavatar] value from GravatarName to any name of your choice. That’s the name that shows up on the gravatar list on your Settings->Discussion page.

That’s it!

Source

email

Comments

  1. says

    Hey Divyansh,

    Thanks for sharing this. I remember reading this on Enstine’s blog yesterday too. Nonetheless, nice tutorial and appreciate the time writing.

    ~Reginald

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>