Add this snippet to functions.php:
function dmeng_get_https_avatar($avatar) { //replace domain $avatar = str_replace(array("www.gravatar.com", "0.gravatar.com", "1.gravatar.com", "2.gravatar.com"), "secure.gravatar.com", $avatar); //replace protocol $avatar = str_replace("http://", "https://", $avatar); return $avatar; } add_filter('get_avatar', 'dmeng_get_https_avatar');
Contributed by dmeng
If visitors of your website is mainly from china mainland, there is a better way, duoshuo (a service similar to disqus) provides a mirror of gravatar, add this snippet to functions.php
//Replace Gravatar with duoshuo mirror function mytheme_get_avatar($avatar) { $avatar = str_replace(array("www.gravatar.com","0.gravatar.com","1.gravatar.com","2.gravatar.com"),"gravatar.duoshuo.com",$avatar); return $avatar; } add_filter( 'get_avatar', 'mytheme_get_avatar', 10, 3 );
Could not know who contributed this method fist, thanks duoshuo!