Gravatar is a great service by Automattic, The team behind WordPress. Many popular online brands are already started integrating it with their products and its by default integrated with WordPress core.
In WordPress default commenting system, Comments are displayed along with the commentators Gravatar. Most of the bloggers and webmaster might be having gravatars but every common user cannot be expected to use gravatar. So when gravatar is not present user will be assigned with default gravatar logo, Like this
But actually you can replace it with some sensible image like your blog logo or some other images to make it unique. So here is how to do it.
Create a 80px*80px squared .png
image with file name custom-avatar.png
and upload it your current themes images
folder. If there is no such folder then create it and upload the logo in it.
Now insert the following lines of code at the end of your current theme’s functions.php
.
add_filter( 'avatar_defaults', 'custom_avatar' ); function custom_avatar($avatar_defaults){ $custom_avatar = get_stylesheet_directory_uri() . '/images/custom-avatar.png'; $avatar_defaults[$custom_avatar] = "My Default Avatar"; return $avatar_defaults; }
Save the file and head over to Settings >> Discussion
. At the end of the settings page you can find your uploaded image like below.
Select “My default Avatar” and save the settings. Thats it you are good to go with.
Your default avatar will be used in comments and author bio when user doesn’t have gravatar.