Last active
August 29, 2015 14:03
-
-
Save lmm214/4aa411901ab1102786c3 to your computer and use it in GitHub Desktop.
七牛云缓存 Gravatar头像(支持头像大小参数)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// By ImMmMm.com 七牛云缓存 Gravatar头像(支持头像大小参数) | |
function qiniu_avatar($avatar) { | |
$avatar = preg_replace('/.*\/avatar\/(.*)\?s=([\d]+)&.*/','<img src="http://你的空间名称.qiniudn.com/avatar/$1-$2" class="avatar avatar-$2" height="$2" width="$2">',$avatar); | |
return $avatar; | |
} | |
add_filter( 'get_avatar', 'qiniu_avatar', 10, 3 ); | |
// WordPress 4.0+ 适用 | |
function qiniu_avatar($avatar) { | |
$avatar = preg_replace('/.*\/avatar\/(.*)\?s=([\d]+)&.*.srcset=.*/','<img src="http://你的空间名称.qiniudn.com/avatar/$1-$2" class="avatar avatar-$2" height="$2" width="$2">',$avatar); | |
return $avatar; | |
} | |
add_filter( 'get_avatar', 'qiniu_avatar', 10, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment