禁用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中完成发送http申请的相干函数解析

在 PHP 中发送 Http 申请(GET / POST)有很多的办法,比方 file_get_contents() 函数、fopen() 函数或许 c...

wordpress制止复制内容的完成办法

1、右键复制时显示提醒语 把上面代码放到footer.php里即可 复制代码代码如下:<html> <head><title>防...

如何进行Wordpress的后盾设置

要害字形容:设置 后盾 进行 如何 这里 Wordpress 选项 能够 网站 你曾经阅读了这个 Wordpress 架设的站点...

WordPress过滤渣滓评论的几种次要办法小结

因为集体博客小站的空间与mysql空间往往无限,共享效劳器资源也无限,所以渣滓评论肯定要阻拦在写入数据库之...

解说WordPress开发中一些罕用的debug技巧

在开发进程中,调试代码是十分重要的工作,而把握一些 WordPress 的调试技巧,能够更好的进行调试。比方,在...

Wordpress自定义函数管制文章题目长度

WordPress显示文章题目的时分,当文章题目过长而且文章的题目又在主页显示时,假如发作换行的景象就显得不美...

需求提交

客服服务

亿鸽在线客服系统