添加代码
将下面代码添加到当前主题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的图像不一样显示
转载自:拾光分享网
作品采用:《 署名-非商业性使用-相同方式共享 4.0 国际 (CC BY-NC-SA 4.0) 》许可协议授权
友情提示:本站项目均为互联网收录,仅供娱乐,折腾需谨慎!
访客
12棒👍🏻