Globally Recognized Avatar or Gravatar is a WordPress’s avatar system which allows an avatar image displayed next to comments made by the user on any WordPress site. The image icon can be a brand representing your company and brand. WordPress comes with a series of default gravatar; this guide shows you how to upload a custom image and use it as the default gravatar in WordPress instead of the default image placeholder.
To upload image to Media library, follow these steps:
Click on Add New, and then click on Select Files to select and upload an gravatar image:
The new gravatar image is listed on the Media Library:
Click on the image, copy the File URL. This URL will be used in the code snippet in the upcoming sections:
To add a default gravatar, follow these steps:
On the Dashboard in the left sidebar, click Appearance, and then click Theme Editor:
On the Theme Editor , select the Theme you want to edit from the dropdown:
The files for this selected theme are listed on the right column under Theme Files. Click on the file named “functions.php”:
Insert the following code to the end of functions.php file:
add_filter( 'avatar_defaults', 'custom_gravatar' ); function custom_gravatar ($avatar_defaults) { $myavatar = 'http://YOUR_WORDPRESS.COM/images/custom_gravatar.png'; $avatar_defaults[$myavatar] = "Default Gravatar"; return $avatar_defaults; }
Copy the URL from Step 5 in Upload an image for gravatar and replace URL for $myavatar in the function.Click Update File button to update the file.
add_filter( 'avatar_defaults', 'custom_gravatar' );
function custom_gravatar ($avatar_defaults) {
$myavatar = 'http://YOUR_WORDPRESS.COM/images/custom_gravatar.png'; //replace this with your the image URL
$avatar_defaults[$myavatar] = "Default Gravatar";
return $avatar_defaults;
}
To view the default gravatar in WordPress, follow these steps:
Scroll down to the Default Avatar section to view the new default Avatar:
Select the new gravatar and click on Save Change:
The gravatar will be displayed beside the username:
Subscribe to receive weekly cutting edge tips, strategies, and news you need to grow your web business.
No charge. Unsubscribe anytime.
Did you find this article helpful? Then you'll love our support. Experience the A2 Hosting difference today and get a pre-secured, pre-optimized website. Check out our web hosting plans today.
We use cookies to personalize the website for you and to analyze the use of our website. You consent to this by clicking on "I consent" or by continuing your use of this website. Further information about cookies can be found in our Privacy Policy.