如何讓圖片自動縮放以適合界面大小,拿出你的Editplus,打開c_function.ASP文件,找到UBBCode函數,在第417行有如下語句
If Instr(strType,"[image]")>0 And ZC_UBB_IMAGE_ENABLE Then
'[img]
objRegExp.Pattern="(\[IMG=)([0-9]*),([0-9]*),(.*)(\])(.+?)(\[\/IMG\])"
strContent= objRegExp.Replace(strContent,"<img src=""$6"" alt=""$4"" title=""$4"" width=""$2"" height=""$3""/>")
objRegExp.Pattern="(\[IMG=)([0-9]*),(.*)(\])(.+?)(\[\/IMG\])"
strContent= objRegExp.Replace(strContent,"<img src=""$5"" alt=""$3"" title=""$3"" width=""$2""/>")
objRegExp.Pattern="(\[IMG\])(.+?)(\[\/IMG\])"
strContent= objRegExp.Replace(strContent,"<img src=""$2"" alt="""" title=""""/>")
End If
在其中加上onload='Javascript:if(this.width>400)this.width=400;',這裡400是要讓超過400的圖片小於400,你可以自己設定寬度.
下面是已經改好的
If Instr(strType,"[image]")>0 And ZC_UBB_IMAGE_ENABLE Then
'[img]
objRegExp.Pattern="(\[IMG=)([0-9]*),([0-9]*),(.*)(\])(.+?)(\[\/IMG\])"
strContent= objRegExp.Replace(strContent,"<img onload='<a href="Javascript:if(this.width>400)this.width=400;'">http://www.knowsky.com/article.asp?typeid=36">Javascript</a>:if(this.width>400)this.width=400;' src=""$6"" alt=""$4"" title=""$4"" width=""$2"" height=""$3""/>")
objRegExp.Pattern="(\[IMG=)([0-9]*),(.*)(\])(.+?)(\[\/IMG\])"
strContent= objRegExp.Replace(strContent,"<img onload='Javascript:if(this.width>400)this.width=400;' src=""$5"" alt=""$3"" title=""$3"" width=""$2""/>")
objRegExp.Pattern="(\[IMG\])(.+?)(\[\/IMG\])"
strContent= objRegExp.Replace(strContent,"<img onload='Javascript:if(this.width>400)this.width=400;' src=""$2"" alt="""" title=""""/>")
End If