中文字幕在线观看,亚洲а∨天堂久久精品9966,亚洲成a人片在线观看你懂的,亚洲av成人片无码网站,亚洲国产精品无码久久久五月天

WordPress禁用gravatar 頭像本地化加速

2018-11-02    來源:學(xué)做網(wǎng)站論壇

容器云強(qiáng)勢上線!快速搭建集群,上萬Linux鏡像隨意使用

WordPress默認(rèn)的頭像是讀取gravatar.com上的圖片的,對(duì)于國內(nèi)用戶來說會(huì)使網(wǎng)頁打開速度變慢。所以如果想提高網(wǎng)頁打開速度(相關(guān)知識(shí):如何測網(wǎng)站訪問速度),可以考慮刪除掉這塊功能。

WordPress禁用gravatar 頭像本地化加速

修改get_avatar函數(shù),在wp-includes/pluggable.php內(nèi)。修改后的函數(shù)如下:

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;

即使用該函數(shù),僅可能返回一個(gè)默認(rèn)頭像(位于wp-includes/images/blank.gif內(nèi)),再配合simple local avatars或Add Local Avatar插件,就實(shí)現(xiàn)了預(yù)期的效果。

相關(guān)知識(shí):wordpress判斷用戶等級(jí)來顯示不同的評(píng)論頭像

標(biāo)簽:

版權(quán)申明:本站文章部分自網(wǎng)絡(luò),如有侵權(quán),請聯(lián)系:west999com@outlook.com
特別注意:本站所有轉(zhuǎn)載文章言論不代表本站觀點(diǎn)!
本站所提供的圖片等素材,版權(quán)歸原作者所有,如需使用,請與原作者聯(lián)系。

上一篇:如何制作WP網(wǎng)站的登錄功能,注冊功能

下一篇:wordpress如何自動(dòng)給圖片加ALT信息、標(biāo)簽云等函數(shù)應(yīng)用匯總