因为各种原因,Aravatar头像被墙,很多朋友会使用Gravatar Fixed这款插件来修正,效果不错。
今天早上看到博客头像挂了,我以前用的是多说的头像缓存,现在发现头像地址变成了http://i2.wp.com/gravatar.duoshuo.com/avatar/ad516503a11cd5ca435acc9bb6523536这个样子,停用Gravatar Fixed,还是不行,后来通过搜索,发现要在functions.php文件里面加入如下代码,就能一劳永逸:
//头像缓存 function duoshuo_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', 'duoshuo_avatar', 10, 3 );