Last update at :2024-05-07,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 has 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
The Begin theme I am currently using supports Cravatar avatars. You only need to enter: cravatar.cn/avatar/ in the custom avatar acquisition address to call the Cravatar avatar.
Reference from:
- Cravatar avatar API documentation
- WordPress integration instructions
Recommended site searches: domain name registration center, foreign cloud servers, US virtual host purchase, local IP address query, how much does server defense cost, registered domain names, US servers, MIIT registration, ICP registration, website query domain name,
p>
发表评论