typecho自定义评论本地随机头像免插件

将下面代码添加到当前主题functions.php中:

    /**
     * 添加随机用户头像
     */
    function local_random_avatar() {
    $options = Typecho_Widget::widget('Widget_Options');
    $thumb= $options->themeUrl .'/imgs/avatar/' . rand(1, 10) . '.jpg';
    $avatar = "<img alt='用户头像' src='{$thumb}' class='avatar avatar-50 photo' />";
    echo $avatar;
    }

使用方法
在要调用头像的地方插入:

    <?php local_random_avatar()?>

下面附赠剪刀手头像一组
QQ20220123114710.jpg

剪刀手QQ头像全套.rar


扫描二维码,在手机上阅读!