添加代码
将下面代码添加到当前主题functions.php中:
[hide]
/**
* 添加随机用户头像
*/
function local_random_avatar($user) {
$options = Typecho_Widget::widget('Widget_Options');
if($user == 'admin'){
$thumb= $options->themeUrl .'/img/avatar-default.png';
}else{
$thumb= $options->themeUrl .'/img/avatar/' . rand(1, 10) . '.png';
}
$avatar = "<img alt='{$user}的头像' src='{$thumb}' class='avatar avatar-50 photo' />";
echo $avatar;
}
[/hide]
使用方法
在要调用头像的地方插入:
<?php local_random_avatar($comments->author)?>
bz的图像不一样显示
转载自:拾光分享网
评论