Gravatars 是Word press默认自带头像同步程序,由于需要在外网服务器读取数据会影响速度。 本文介绍如何将Gravatar 本地化。
需要下载simple local avatars插件安装。
然后修改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;
成功
参考链接:http://www.jb51.net/cms/119613.html
Simple local avatar 官方地址:https://wordpress.org/plugins/simple-local-avatars/