| 一直被Dicsuz X2沒有辦法設(shè)置遠(yuǎn)程鏈接圖片的Alt屬性而困擾,找了一些資料以后,自己又鼓搗鼓搗,終于解決了這個(gè)問題,下面把方法跟大家共享一下: 1. 找到這個(gè)文件: \source\function\function_discuzcode.php
 2. 找到大約201行,原來的代碼:
 
 復(fù)制代碼$attrsrc = !IS_ROBOT && $lazyload ? 'file' : 'src';
if(strpos($msglower, '[/img]') !== FALSE) {
$message = preg_replace(array(
"/\[img\]\s*([^\[\<\r\n]+?)\s*\[\/img\]/ies",
"/\[img=(\d{1,4})[x|\,](\d{1,4})\]\s*([^\[\<\r\n]+?)\s*\[\/img\]/ies"
), $allowimgcode ? array(
"bbcodeurl('\\1', '<img $attrsrc="{url}" onload="thumbImg(this)" alt="" />')",
"parseimg('\\1', '\\2', '\\3', ".intval($lazyload).")"
修改后的代碼
 復(fù)制代碼$attrsrc = !IS_ROBOT && $lazyload ? 'file' : 'src';
$imgalt = $_G[forum_thread][short_subject];
if(strpos($msglower, '[/img]') !== FALSE) {
$message = preg_replace(array(
"/\[img\]\s*([^\[\<\r\n]+?)\s*\[\/img\]/ies",
"/\[img=(\d{1,4})[x|\,](\d{1,4})\]\s*([^\[\<\r\n]+?)\s*\[\/img\]/ies"
 ), $allowimgcode ? array(
 "bbcodeurl('\\1', '<img $attrsrc="{url}" onload="thumbImg(this)" alt=".$imgalt." />')",
 "parseimg('\\1', '\\2', '\\3', ".intval($lazyload).")"
3.找到大約596行,原來的代碼:
 
 修改后的代碼:復(fù)制代碼return bbcodeurl($src, '<img'.($width > 0 ? ' width="'.$width.'"' : '').($height > 0 ? ' height="'.$height.'"' : '').' '.$attrsrc.'="'.$src.'"'.$extra.' border="0" alt="'.$imgalt.'" />');
 4. 修改完成.其中$_G[forum_thread][short_subject]為短標(biāo)題,用起來正合適,不過,此項(xiàng)改動,有SEO過度的嫌疑,可以繼續(xù)優(yōu)化一下,大家就自己來調(diào)整吧.5. 如果大家自己不愿意修改,可以直接下載修改過的function_discuzcode.php文件.復(fù)制代碼 $imgalt = $_G[forum_thread][short_subject];
return bbcodeurl($src, '<img'.($width > 0 ? ' width="'.$width.'"' : '').($height > 0 ? ' height="'.$height.'"' : '').' '.$attrsrc.'="'.$src.'"'.$extra.' border="0" alt="'.$imgalt.'" />');
聲明: 本文系"玩改車"原創(chuàng)文章,轉(zhuǎn)載請注明出處,謝謝.
 
 
 
 
 |