Unable to load Gravatar global avatar properly? Cravatar, the perfect alternative to Gravatar avatars in mainland China, is released

888u

Last update at :2024-01-22,Edit by888u

Since mainland China has been unable to load the Gravatar global avatar normally, it has seriously slowed down the loading speed of WordPress. In addition, some novices may not know how to apply for an avatar. Recently, the author of the WP-China-Yes plug-in once again launched and launched Cravatar, a perfect alternative to Gravatar avatars in mainland China.

Cravatar is fully compatible with Gravatar's API specification and supports users to upload and share avatars. Cravatar avatar application address

Enter the Cravatar avatar website, register with your usual email address, and click "Create your avatar now" after logging in.

Upload an avatar picture, use your registered email address to leave a message on a website that supports avatars, and you will see your own Cravatar avatar.

So how to integrate the Cravatar avatar service into your own WordPress website?

It's very simple, just add the following code to the current theme function template functions.php:

if ( ! function_exists( 'get_cravatar_url' ) ) { /** * Replace Gravatar avatar with Cravatar avatar * * Cravatar is the perfect alternative to Gravatar in China, you can update your avatar at https://cravatar.cn */ 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 ); } if ( ! function_exists( 'set_defaults_for_cravatar' ) ) { /** * Replace default avatar in WordPress discussion settings */ function set_defaults_for_cravatar( $avatar_defaults ) { $avatar_defaults['gravatar_default'] = 'Cravatar flag'; return $avatar_defaults; } add_filter( 'avatar_defaults', 'set_defaults_for_cravatar', 1 ); }

In the future, the Cravatar avatar will replace Gravatar, the avatar loading speed will be significantly improved, and there is no need to cache the avatar locally.

When the QQ mailbox used by the commenter does not apply for an avatar, Cravatar will automatically call the QQ avatar, which is very user-friendly.

In addition, you can also try to install: LitePress China’s local WordPress distribution

For example, the Begin theme currently used by some webmasters supports Cravatar avatars. You only need to enter: cravatar.cn/avatar/ in the custom avatar acquisition address to call the Cravatar avatar.

Referenced from:

  • Cravatar avatar API documentation
  • WordPress integration instructions

Recommended site search: query IP address, Hong Kong cloud host, free domain name, ASP free space application, network domain name, Hong Kong server hosting, independent IP space, Korean proxy server, free domain name, domain name query,

Unable to load Gravatar global avatar properly? Cravatar, the perfect alternative to Gravatar avatars in mainland China, is released

All copyrights belong to 888u unless special state
取消
微信二维码
微信二维码
支付宝二维码