Solve the problem that the remote Gravatar profile picture is not displayed

Source: Internet
Author: User
Gravatar's profile picture is now a common method for calling blogs. many of my friends' personal blogs use Gravatar's profile picture, but recently many webmasters have found it slow to open Gravatar's profile picture, so how can we solve the problem of Gravatar Image playing... gravatar's profile picture is now a common method for calling blogs. many of my friends' personal blogs use Gravatar's profile picture, but recently many webmasters have found it slow to open Gravatar's profile picture, so how can we solve the problem that Gravatar images cannot be opened or are opened slowly? Let's take a look.

First, if we still need to use the Gravatar Avatar

 

Add the above code to the FUNCTIONS. PHP page of the current WORDPRESS topic. because HTTP cannot be accessed directly, it is changed to the HTTPS path address.

2. use a local Avatar

function my_avatar($avatar) {    $tmp = strpos($avatar, 'http');    $g = substr($avatar, $tmp, strpos($avatar, "'", $tmp) - $tmp);    $tmp = strpos($g, 'avatar/') + 7;    $f = substr($g, $tmp, strpos($g, "?", $tmp) - $tmp);    $w = get_bloginfo('wpurl');    $e = ABSPATH .'avatar/'. $f .'.jpg';    $t = 1209600;    if ( !is_file($e) || (time() - filemtime($e)) > $t ) {        copy(htmlspecialchars_decode($g), $e);    } else{        $avatar = strtr($avatar, array($g => $w.'/avatar/'.$f.'.jpg'));    }    if (filesize($e) < 500)    {        copy($w.'/avatar/default.jpg', $e);    }    return $avatar;}add_filter('get_avatar', 'my_avatar');

Images are displayed as pictures that do not exist by default.

Third, use third-party comment plug-ins

Third-party comment plug-ins can be used to display portraits. Currently, there is no call problem. I have previously written an article titled "comment on four social comment systems ", currently, many users are still talking about it. The former provides a good user experience, that is, the server downtime is unstable. The latter is based on Sohu's interface, but the server is relatively stable.


Address:

Reprinted at will, but please attach the article address :-)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.