禁用wordpress gravatar使用本地头像提高网页打开速度

前端之家收集整理的这篇文章主要介绍了禁用wordpress gravatar使用本地头像提高网页打开速度前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

wordpress默认的头像是读取gravatar.com上的图片的,对于国内用户来说会使网页打开速度变慢。所以我决定删除掉这块功能修改get_avatar函数,在wp-includes/pluggable.PHP内。修改后的函数如下: <div class="msgborder" id="PHPcode33"> 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;

原文链接:https://www.f2er.com/wordpress/15330.html

猜你在找的wordpress相关文章