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='javascript: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
本文介绍了一种通过编辑c_function.asp文件中的UBBCode函数来实现图片自适应缩放的方法,确保图片宽度不超过指定数值,适用于网页界面优化。

被折叠的 条评论
为什么被折叠?



