论坛里面有人问过,今天闲来无事研究了一下发现很容易实现,跟去除贴内图片下载提示的方法一样,都是通过修改template/default/forum/discuzcode.htm里面代码的原理。
详情查看Discuz x3.2 去掉图片附件下载提示的方法
第一步查找
1 | <img{if $attach['price'] && $_G['forum_attachmentdown'] |
完整代码:
1 | <img{if $attach['price'] && $_G['forum_attachmentdown'] && $_G['uid'] != $attach['uid']} class="attprice"{/if} id="aimg_$attach[aid]" aid="$attach[aid]" src="{STATICURL}image/common/none.gif" zoomfile="{if $attach[refcheck]}forum.php?mod=attachment{$is_archive}&aid=$aidencode&noupdate=yes&nothumb=yes{else}{$attach[url]}$attach[attachment]{/if}" file="{if $attach[refcheck]}forum.php?mod=attachment{$is_archive}&aid=$aidencode&noupdate=yes{else}{$attach[url]}$attach[attachment]{/if}" $widthcode id="aimg_$attach[aid]" inpost="1"{if $_GET['from'] != 'preview'} {/if} /> |
然后在
1 | inpost="1"{if $_GET['from'] != 'preview'} |
前方加标签
discuz的标签调用如下:
1 2 3 | $_G[forum_thread][subject] 文章标题 $_G[setting][sitename] 网站名称 $attach[imgalt] 图片名称 |
我们根据这三个标签可以实现图片alt信息显示文章标题还是显示网站名称又或者显示图片名称。个人推荐显示文章标题,因为图片名称是一串数字..
增加方法:
1 | alt="$_G[forum_thread][subject] " title="$_G[forum_thread][subject]" |
直接将上述代码插入到
1 | inpost="1"{if $_GET['from'] != 'preview'} |
前方即可实现
修改完成后的代码:
1 | <img{if $attach['price'] && $_G['forum_attachmentdown'] && $_G['uid'] != $attach['uid']} class="attprice"{/if} id="aimg_$attach[aid]" aid="$attach[aid]" src="{STATICURL}image/common/none.gif" zoomfile="{if $attach[refcheck]}forum.php?mod=attachment{$is_archive}&aid=$aidencode&noupdate=yes&nothumb=yes{else}{$attach[url]}$attach[attachment]{/if}" file="{if $attach[refcheck]}forum.php?mod=attachment{$is_archive}&aid=$aidencode&noupdate=yes{else}{$attach[url]}$attach[attachment]{/if}" $widthcode id="aimg_$attach[aid]" alt="$_G[forum_thread][subject] " title="$_G[forum_thread][subject] " inpost="1"{if $_GET['from'] != 'preview'} {/if} /> |