WordPress cache Gravatar avatar compact mini version

Caching Wordpress avatar always uses a component Generic Gravatar Cache , which has been used for a long time. But it will generate a lot of useless garbage in the cache directory! Very unhappy. Do you want to clean it? Now it's good. The method is particularly simple. Just modify the source code. The test is all right

Well, there's a lot of nonsense. Let's see how to change it. My theme is inove (randomly modified), so change the functions.php in the root directory of the theme Find this line:

 <img src='/index/thumb.png' data-original="***" alt="" width="32" height="32" />

In fact, it is in the comments. Add the following code in front of it:

 <? php $f = md5(strtolower($comment->comment_author_email)); $a = get_bloginfo('wpurl') .'/ gravatar/'.$f.'.jpg'; $e = ABSPATH . ' gravatar/'.$f.'.jpg'; $t = 1209600; $d = get_bloginfo('wpurl'). '/ gravatar/default-gravatar.jpg'; if ( ! is_file($e) || (time() - filemtime($e)) > $t ){ $r = get_option('avatar_rating'); $g = ' http://www.gravatar.com/avatar/ '.$ f.'?s=32&d='.$d.'&r='.$r; copy($g, $e); } if (filesize($e) < 500) {copy($d, $e);} ?>

It's so simple. Have you seen the effect?
Nothing else needs to be changed. The sidebar can be used again. Theoretically, it can be called as a function. Unfortunately, I'm a novice and don't understand

It's said to be from Master Willin Mini gravatar avatar cache method

Appreciation

see wordpress php gravatar Related articles for

Please specify that the original article of this website is reproduced from To be kicked , Link: https://itlu.net/articles/1406.html

Comment list (5)

  1. Zb's passing
    I've always wanted to turn to wp, but unfortunately I can't

  2. @Self study Examination of Engineering University
    In fact, it's not difficult. There have been many successful cases

  3. This is good. I'm trying to change it.

  4. I have integrated this function

  5. @Xiao Wu
    It's said that there is a better version of this thing. I'm going to steal one

    @Yipin Element
    Well, much better than before

Add a comment

Hello! #Please fill in the information# determine

Reward the blogger for drinking water
 LOADING