Gavatar的頭像在國內不能正常訪問,如圖:
把以下php代碼添加到模板函數funtions.php文件中
if ( ! function_exists( get_cravatar_url ) ) { /** * 把Gravatar頭像服務替換為Cravatar * @param string $url * @return string */ function get_cravatar_url( $url ) { $sources = array( www.gravatar.com, 0.gravatar.com, 1.gravatar.com, 2.gravatar.com, secure.gravatar.com, cn.gravatar.com ); return str_replace( $sources, cravatar.cn, $url ); } add_filter( um_user_avatar_url_filter, get_cravatar_url, 1 ); add_filter( bp_gravatar_url, get_cravatar_url, 1 ); add_filter( get_avatar_url, get_cravatar_url, 1 );}
2,從后臺添加代碼添加完代碼,后 更新文件 按鈕保存
設置完之后,頭像已可正常顯示
說明:劉宏締的架構森林是一個專注架構的博客,地址:https://www.cnblogs.com/architectforest
對應的源碼可以訪問這里獲取:https://github.com/liuhongdi/ 或:https://gitee.com/liuhongdi
說明:作者:劉宏締 郵箱: 371125307@qq.com
可以看到頭像都已可以正常顯示
聲明:所有內容來自互聯網搜索結果,不保證100%準確性,僅供參考。如若本站內容侵犯了原著者的合法權益,可聯系我們進行處理。