Home > php教程 > PHP源码 > 远程使用gravatar头像

远程使用gravatar头像

PHP中文网
Release: 2016-05-25 17:13:04
Original
1363 people have browsed it

远程使用gravatar头像

function get_gravatar( $email, $s = 80, $d = 'mm', $r = 'g', $img = false, $atts ='吕滔') {
	$url = 'http://www.gravatar.com/avatar/';
	$url .= md5( strtolower( trim( $email ) ) );
	$e = ROOT_PATH . 'image/user/'.md5( strtolower( trim( $email ) ) ).'.jpg';
	$t = 1209600; 
	$url .= "?s=$s&d=$d&r=$r";
	if ( !is_file($e) || (time() - filemtime($e)) > $t ){//当头像不存在或文件超过14天才更新
		copy($url , $e);//拷贝到本地,一般主机都支持这个函数
	}
	$url=$e;
	if ( $img ) {
		$url = '';
	}
	return $url;
}
Copy after login

使用方法

return get_gravatar($emails,'80','wavatar','g',false);
Copy after login

以上就是远程使用gravatar头像的内容,更多相关内容请关注PHP中文网(www.php.cn)!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template