discuz論壇教程之帖中圖片附件添加alt描述的快捷方法,對于圖片的優化至關重要,因為搜索引擎不能識別圖片,智能通過alt標簽來識別,那么你知道alt的用途了嗎,如果還不知道,盡快學習下吧!
大家都是知道給圖片<img>標簽添加alt描述對于SEO的重要性,但是作為國內使用范圍最廣的discuz!論壇程序卻默認沒有添加alt描述,現在本文介紹一種簡單的方法來幫助站長快速設置圖片alt屬性,方法如下:
打開模板文件:/template/default/forum/discuzcode.htm
找到如下代碼(discuz! X3.2大概在257行左右,其他版本請自行搜索):
<!--{if $_G['setting']['thumbstatus'] && $attach['thumb']}-->
<img{if $attach['price'] && $_G['forum_attachmentdown'] && $_G['uid'] != $attach['uid']} class="attprice"{/if} style="cursor:pointer" id="aimg_$attach[aid]" aid="$attach[aid]" src="{STATICURL}image/common/none.gif" onclick="zoom(this, this.getAttribute('zoomfile'), 0, 0, '{$_G[setting][showexif]}')" zoomfile="{if $attach[refcheck]}forum.php?mod=attachment{$is_archive}&aid=$aidencode&noupdate=yes¬humb=yes{else}{$attach[url]}$attach[attachment]{/if}" file="{if $attach[refcheck]}forum.php?mod=attachment{$is_archive}&aid=$aidencode{else}{$attach[url]}$attachthumb{/if}" inpost="1"{if $_GET['from'] != 'preview'} onmouseover="showMenu({'ctrlid':this.id,'pos':'12'})"{/if} />
<!--{else}-->
<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¬humb=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'} onmouseover="showMenu({'ctrlid':this.id,'pos':'12'})"{/if} />
<!--{/if}-->
改成下面的:
<!--{if $_G['setting']['thumbstatus'] && $attach['thumb']}-->
<img />
【*】注意以上修改代碼時請注意使用代碼編輯器,不要再記事本中修改,切記!
新聞熱點
疑難解答