DISCUZ 如何为主题帖列表页添加头像,显示发帖者头像


只显示名字的代码

```php
<em style=" font-size:14px;">
<!--{if $thread['authorid'] && $thread['author']}-->
<a href="home.php?mod=space&uid=$thread[authorid]" c="1"{if $groupcolor[$thread[authorid]]} style="color: $groupcolor[$thread[authorid]];"{/if}> $thread[author]</a><!--{if !empty($verify[$thread['authorid']])}--> $verify[$thread[authorid]]<!--{/if}-->
<!--{else}-->
$_G[setting][anonymoustext]
<!--{/if}-->
</em>
```


修改后可显示头像的代码,(我把头像加上后把显示名字注释掉了)

```php
<em style=" font-size:14px;">
<!--{if $thread['authorid'] && $thread['author']}-->
<a href="home.php?mod=space&uid=$thread[authorid]" c="1"{if $groupcolor[$thread[authorid]]} style="color: $groupcolor[$thread[authorid]];"{/if}> <img src="/uc_server/avatar.php?uid=$thread[authorid]&size=small"><!--$thread[author]--> </a><!--{if !empty($verify[$thread['authorid']])}--> $verify[$thread[authorid]]<!--{/if}-->
<!--{else}-->
$_G[setting][anonymoustext]
<!--{/if}-->
</em>
```

DZ获取头像的 是/uc_server/avatar.php?uid=$thread[authorid]&size=small
其中size=small 就是获取最小尺寸的那个头像 所以不用在给img 加尺寸控制了 不会影响排版~

效果图

 

原文地址:https://www.cnblogs.com/yangqiangche/p/12284413.html