一,默认头像效果:
Gavatar的头像在国内不能正常访问,如图:![](/i/l/?n=23&i=blog/1938691/202305/1938691-20230504150017886-1056930117.png)
二,设置:
把以下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,从后台添加代码
![](/i/l/?n=23&i=blog/1938691/202305/1938691-20230504150018021-1152432486.png)
![](/i/l/?n=23&i=blog/1938691/202305/1938691-20230504150017881-222732783.png)
说明:刘宏缔的架构森林是一个专注架构的博客,地址:https://www.cnblogs.com/architectforest
对应的源码可以访问这里获取: https://github.com/liuhongdi/
或: https://gitee.com/liuhongdi
说明:作者:刘宏缔 邮箱: [email protected]
三,测试效果
![](/i/l/?n=23&i=blog/1938691/202305/1938691-20230504150017911-1534557678.png)
四,查看wordpress的版本:
![](/i/l/?n=23&i=blog/1938691/202304/1938691-20230428170821826-234541502.png)