禁用wordpress gravatar应用本地头像进步网页关上速度

WordPress默许的头像是读取gravatar.com上的图片的,关于国际用户来说会使网页关上速度变慢。所以我决议删除掉这块性能。

修正get_avatar函数,在wp-includes/pluggable.php内。修正后的函数如下:
 
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;

即便用该函数,仅可能前往一个默许头像(位于wp-includes/images/blank.gif内),再配合simple local avatars或Add Local Avatar插件,就完成了预期的成果。

以上就是安达网络工作室关于《禁用wordpress gravatar使用本地头像提高网页打开速度》的一些看法。更多内容请查看本栏目更多内容!

本文相关话题: wordpress 禁用gravatar 本地头像
版权声明:本文为 安达网络工作室 转载文章,如有侵权请联系我们及时删除。
相关文章
WordPress后盾显示相干用户文章相干联评论的办法

本文实例讲述了WordPress后盾显示相干用户文章相干联评论的办法。分享给大家供大家参考。详细剖析如下: 将...

WordPress中"无奈将上传的文件挪动至"谬误的处理办法

明天在网页上传图片到博客,后果提醒:“无奈将上传的文件挪动至 /home/wwwroot/wp-content/uploads/2013/”...

8个出色的WordPress SEO插件搜集

wordpress是以后网终上最的行的内容公布工具之一。它领有不计其数的收费主题和插件,协助老手不便快捷地将内...

详解WordPress中的头像缓存和代理中的缓存更新办法

wordpress评论中的头像是应用Gravatar的头像效劳(Gravatar民间注册地址:http://en.gravatar.com),用户的...

在WordPress中获取数据库字段内容和增加主题设置菜单

get_option() 函数应用技巧 get_option()这个函数,实际上咱们在整合后盾性能的时分常常会用到的一个函数,...

wordpress模板罕用函数集锦

根本模板文件 style.css : CSS(款式表)文件index.php : 主页模板archive.php : Archive/Category模板404.ph...

需求提交

客服服务

亿鸽在线客服系统