If you use the default WordPress comments on your WordPress blog, then you would most probably be displaying the images of the commenters along with their comment. This image is displayed using a third-party service called Gravatar.
For people who do not have a Gravatar account, Gravatar displays a default image, which the site administrator can choose from the WordPress dashboard (Settings > Discussion). But there’s a limitation though. Gravatar does not allows you to set any custom image as the default image for WordPress comments, but we have a small snippet to help you with this.
Related Articles
- Doing Complete SEO Of Your WordPress Website With WordPress SEO By Yoast
- Turn OFF Autosave In WordPress And Reduce Database Size
- Optimizing Database For WordPress Websites Automatically [Free Plugin]
- How to Edit .htaccess File from WordPress Dashboard Itself
- 4 Ways To Enable Gzip Compression In WordPress
Set Custom Image As Gravatar Default
Adding the below code to your functions.php will make the image gravatar.jpg stored in your active theme’s directory under the folder images as the default image for Gravatar.
function default_gravatar ($avatar_defaults) {
$myavatar = get_bloginfo('template_directory') . '/images/gravatar.jpg';
$avatar_defaults[$myavatar] = "Default Gravatar";
return $avatar_defaults;
}
add_filter( 'avatar_defaults', 'default_gravatar' );