Explaining how to change the default Gravatar in WordPress and replace it with an image that expresses you

or store on WordPress, it is preferable to start using avatar images known as (Gravatar), as these images create a virtual icon that appears next to the names of users who write comments or publish posts on the website.

You can use the Gravatar avatar service, which we will explain in today’s article, to create your own avatar to appear in specific places within your site and in all of your comments and posts in various WordPress blogs and websites. You can also activate the display of avatar images for all users on your WordPress site, as this image will appear next to the user name when he writes comments or posts on your site.

In this article, you will learn how to deal with the concept of a Gravatar, and how you can add or change it to your WordPress site in easy and simple steps.


Gravatar concept

Gravatar is a free web service for avatars. Created and operated by Matt Mullenweg. It allows anyone to create a personal profile and an avatar for themselves through this service, and link these avatars to their email address.

The word Gravatar is an abbreviation for the phrase “Globally Recognized Avatar,” which means a globally recognized avatar, which is the image used to represent you in the Internet world and which will appear next to your name when you interact with any site that supports this service.

Thus, you will only need to upload your public profile picture once, and after that, when you participate in any site that supports the Gravatar service, your profile and public avatar will be automatically attached there to express your personal identity.

Previously, users had to register on forums or blogs to be allowed to comment and participate. Thus, the user had a personal profile for each site on which he registered an account, and he could put his photo or icon in this profile. 

Today, most sites enable you to write comments or other contributions without you logging in, and identify you only by your email.

What is the role of Gravatar, and why should you use it?

The Gravatar service is implicitly integrated into many global applications and platforms, including WordPress. For example, if you select your Gravatar image, and then go to any WordPress site and write a comment, you will notice that your Gravatar image will automatically be pulled, and this image will appear next to your username.

Therefore, it is preferable to start using Gravatar if you want to have an identity that distinguishes you, enhances your presence in the web world, and helps you build a better relationship with other users.


How do you create a Gravatar image and link it to your account?

If the user does not have a Gravatar image, WordPress will automatically show the default Gravatar image. If you do not want to use the default Gravatar image, you can change it to your image or the icon that represents you, as we will explain in the following lines.

You can create your own Gravatar image, and link it to the email you want, so that the image will be used automatically as soon as you register on a site or comment on a site with the same email, by following these steps:

  1. Go to the official website of the service.
  2. Then register and create a new account on the site, using the email you use frequently.
  3. After that, you can log in to your personal account and enter the information you want to associate with the email (such as name, bio), etc., as well as upload and select the Gravatar image you want. 

After that, when you use the email, the image and information you entered will be automatically used where users leave their comments or posts. All WordPress sites come with Gravatars built-in and automatically display user avatars.

The default Gravatar image in WordPress can easily be changed in several ways, whether in the control panel itself, through custom code, or using the WP User Avatar plugin . Let us now explain these methods as follows:

1- Change the default Gravatar image through the WordPress control panel

From within your site’s WordPress control panel, you can change the default avatar used for members who do not have their own avatar. WordPress gives you the option to display a general avatar for all of these members, or display a unique avatar based on their email addresses.

This is done through the control panel , then going to Settings > Discussion. Then you can scroll down to see the options available for your default avatar. 

You can choose from the existing images and click Save Changes, as shown in the following image:

In this method, you don’t have much choice. Likewise, you cannot add images customized for you. However, if you need to add a specific image that you have on your computer and want to upload it to become your avatar, you can do so by adding a special code to your WordPress files, as we will explain in the following paragraph.

2- Use the code to change the Gravatar image

If you want to add custom avatars and then upload them to your site, you must do the following. First, you must upload the images to your WordPress site by going to Media > Add New > then dragging or selecting the files to upload.

Note: The dimensions of the images must be square, for example (250*250). After that, you must click on Edit to edit and modify the image.

A new window will open for you. You must copy the URL file link from it, as shown in the following image.

Next, you will have to add code inside the functions.php file in WordPress. This is a theme function file and is mainly used to add new features or modify the default features in a WordPress website. 

Note:  If you do not have sufficient programming experience, it is preferable not to follow this method and go directly to method No. 3, which relies on adding (WP User Avatar), because any error in writing the code in the functions.php file may cause your WordPress site to crash.

It is also preferable to make a backup copy of your site before making the modification, to restore it in the event of any errors in modifying the code.

To find this file you need to go to Appearance > Theme Editor > and then look for the file functions.php 

Open the file and find the definition of the variable myavatar inside the file, as shown in the following image: 

Here you must pay attention and replace the value of the myavatar variable with the value of the previous link – located within the red box – with the link to the new file that you copied in the previous step (i.e. the link to the new image).

The code becomes as follows:

If the variable does not exist, declare it manually by editing the file and adding the following code before the closing bracket { at the end of the file: 

add_filter( ‘avatar_defaults’, ‘wpb_new_gravatar’ );
function wpb_new_gravatar ($avatar_defaults) { $myavatar=’http://test.default.org/wp-content/uploads/2021/05/gravatar-icon1.jpeg’;
$avatar_defaults[$myavatar] = “Custom Gravatar”;
return $avatar_defaults;

 After adding the required code into the functions.php file  , as shown in the following image, click the Update File button.

After that you can go back to Settings > Discussion , to find the new image you added where you can now select it as your default avatar.

 

3- Use the WP User Avatar plugin to change avatar images

The WP User Avatar plugin allows you to set any image you want as the default avatar, and it also enables you to upload and download the avatar images you want. The free version of the add-on is decent and does the trick, but the paid version comes with more options (such as the ability to use your webcam to take avatars).

You can download the add-on by going to Add-ons > Add New and typing WP User Avatar in the search box , then clicking the  Install Now button.

Then click on the Activate button to activate the add-on on your site.

To see more information about how to install the plugin, I advise you to read the following article:  Installing the WordPress plugin correctly. Once you activate the plugin, you can go to Settings > Discussion , and you will notice that a button has been added called Choose Image . You can click on it to add and upload the avatars that you want. You want it for the site.

When you click the  Choose Image button , the Media Library window will open. You can choose an image from the media library or go to the Upload Files tab to upload a new image from your device, for example.

The image will be downloaded and set as the default image. Select the image you want and then click the Save Changes button. 

You will notice that your profile avatar has changed. 

Now that you have selected the Gravatar image, WordPress will set this image as the default for all users who have not linked the Gravatar to their email addresses.

To try this, you can go to your site and try writing a comment, and you will see how the Gravatar image you chose in the previous step will be linked to your comment.

In the end, the process of changing the default Gravatar image in WordPress is an easy and simple process, and you can do it in simple ways even if you do not have technical or programming experience. 

Today’s article has shown you three options available to change the image. You can change the image and choose a new image from among the available images, or you can upload a new image and add it to your site manually by modifying the code if you have programming information, or you can use the WP User Avatar add-on to upload and set Create your own avatars easily and without modifying any code. Choose one method that suits you and start applying it to your site

Avatar photo
I am a young man who has been working in WordPress and e-marketing for 10 years. I would like to share my experience with you so that we can become professional in WordPress I will be happy to share the experience with you.