[收起] 文章目錄

  • 適用 X2 、 X2.5
  • 適用 X3
  • 相關下載

站點圖片做 alt 資訊對於 SEO 的最佳化還是挺重要的。

直接說方法吧!

要是懶得修改或者不會修改的,直接到下邊下載檔案來進行修改吧!

開啟自己站點的 /template/default/forum/discuzcode.htm 檔案

查詢 alt="$attach[imgalt]" title="$attach[imgalt]" ,這個有多個地方,大概是 6 處,找到的地方全部替換為

X2 、 x2.5 替換程式碼
XHTML

1
alt="$_G[forum_thread][subject] - $_G[setting][sitename] - $attach[imgalt]" title="$_G[forum_thread][subject] - $_G[setting][sitename] - $attach[imgalt]"

替換完了以後,儲存即可。然後登入後臺,工具 - 更新快取即可。

 

查詢 alt=$attach['price'],大概在 258 行和 260 行,一共有兩個 $attach['price']

將 258-260 行,三行程式碼替換成下面的

X3 - 258-260 行替換程式碼
XHTML

1

2

3
<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" alt="$_G[forum_thread][subject] - $_G[setting][sitename] - $attach[imgalt]" title="$_G[forum_thread][subject] - $_G[setting][sitename] - $attach[imgalt]" {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" alt="$_G[forum_thread][subject] - $_G[setting][sitename] - $attach[imgalt]" title="$_G[forum_thread][subject] - $_G[setting][sitename] - $attach[imgalt]" {if $_GET['from'] != 'preview'} onmouseover="showMenu({'ctrlid':this.id,'pos':'12'})"{/if} />

替換完了以後,儲存即可。然後登入後臺,工具 - 更新快取即可。

以上兩個替換程式碼的 alt 和 title 的顯示順序是:帖子標題-站點名稱-圖片名稱,這些可自行修改。這裡就不教如何修改了,自己看下程式碼就知道了。

2015-05-03T16:43:55+08:00發表於:2015-05-03|Discuz!|