RSS订阅追求最高效、最简单的解决方案
你的位置:首页 » web开发课堂 » 正文

wp模版禁用gravatar头像服务器方法

选择字号: 超大 标准 技术小哥 发布于2016年02月19日 属于 web开发课堂 栏目  0个评论 2740人浏览

WordPress默认的头像是读取gravatar.com上的图片的,对于国内用户来说会使网页打开速度变慢。尤其是这几年长城防火墙封锁的厉害会造成WP模版的站点访问速度非常缓慢!

那么修改get_avatar函数,在wp-includes/pluggable.php内,找到之后先搜索到get_avatar这个函数,将这段代码换成下方这段,再保存即可


if ( !function_exists( 'get_avatar' ) ) : 
/** 
* Retrieve the avatar for a user who provided a user ID or email address. 

* @since 2.5 
* @param int|string|object $id_or_email A user ID, email address, or comment object 
* @param int $size Size of the avatar image 
* @param string $default URL to a default image to use if no avatar is available 
* @param string $alt Alternate text to use in image tag. Defaults to blank 
* @return string tag for the user's avatar 
*/ 
function get_avatar( $id_or_email, $size = '96', $default = '', $alt = false ) { 
if ( ! get_option('show_avatars') ) 
return false; 
if ( false === $alt) 
$safe_alt = ''; 
else 
$safe_alt = esc_attr( $alt ); 
if ( !is_numeric($size) ) 
$size = '96'; 
$default = includes_url('images/blank.gif'); 
$avatar = ""; 
return apply_filters('get_avatar', $avatar, $id_or_email, $size, $default, $alt); 

endif; 


备注:请修改的时候注意看清endif结束部分,不要把其他函数给覆盖了。

打赏

标签:gravatar.wp模版wordpress

1

猜你喜欢

右侧2016一起努力
最新发布的文章
最新评论

公告

十年相伴 值得信赖 需要定制开发、购买加速器可以联系 QQ1368762345,微信同号