回复 伴我飞 的帖子
请在\source\function\common.func.php加入以下代码
//处理头像
function avatar($uid, $size='small', $returnsrc = FALSE) {
global $_SCONFIG, $_SN;
$size = in_array($size, array('big', 'middle', 'small')) ? $size : 'small';
$avatarfile = avatar_file($uid, $size);
return $returnsrc ? UC_API.'/data/avatar/'.$avatarfile : '<img src="'.UC_API.'/data/avatar/'.$avatarfile.'" onerror="this.onerror=null;this.src=\''.UC_API.'/images/noavatar_'.$size.'.gif\'">';
}
//得到头像
function avatar_file($uid, $size) {
global $_SGLOBAL, $_SCONFIG;
$type = empty($_SCONFIG['avatarreal'])?'virtual':'real';
$var = "avatarfile_{$uid}_{$size}_{$type}";
if(empty($_SGLOBAL[$var])) {
$uid = abs(intval($uid));
$uid = sprintf("%09d", $uid);
$dir1 = substr($uid, 0, 3);
$dir2 = substr($uid, 3, 2);
$dir3 = substr($uid, 5, 2);
$typeadd = $type == 'real' ? '_real' : '';
$_SGLOBAL[$var] = $dir1.'/'.$dir2.'/'.$dir3.'/'.substr($uid, -2).$typeadd."_avatar_$size.jpg";
}
return $_SGLOBAL[$var];
} |