Show Custom Avatar Images in Comments
Gravatar is a great service by Automattic, the folks behind WordPress. In Gravatar, you designate your online profile picture one the one website. Whenever you sign in with this address on another website, it can display your universal Gravatar image.
In the default WordPress Comment system, each comment will be displayed alongside an image from the Gravatar service. If the user has not signed up with the service before or is unknown, then the WordPress page will display a random image. If you want to customize what this random image is, all you need to do is add the following lines of code to your functions.php file:
add_filter('avatar_defaults', 'add_custom_gravatar'); function add_custom_gravatar($avatar_defaults) { $myavatar = get_bloginfo('template_directory') . '/images/custom-gravatar.png'; $avatar_defaults[$myavatar] = "Custom Gravatar"; return $avatar_defaults; }
In the above example, the ‘custom-gravatar.png’ image would be located inside the Theme’s images folder: /yourtheme/images/custom-gravatar.png
When creating your Custom Avatar image, the dimensions should be: 80px x 80px square.
Leave a Reply