Gravatar has been loading very slowly in mainland China recently, and in some places it does not load at all. Since WordPress uses Gravatar for default comment avatars, this can make both the WordPress dashboard and front-end post pages load much more slowly. One workaround is to disable avatars entirely in the WordPress settings, but that makes comment pages look unattractive. In practice, we only need to filter the avatar output and replace the Gravatar host with Duoshuo. The code is below.
function wizhi_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', 'wizhi_get_avatar', 10, 3 );
Just paste the code above into your WordPress theme’s functions.php file, then open a post that has comments and test it. The page should open much faster right away.
This feature has also been integrated into my wizhi-optimization plugin, so you can also get it directly by installing the plugin.
