Blueimp 論壇首頁


列印 2024/4/19 下午 06:29:42

文章作者 jieh2007/10/25 上午 11:59:06
smile   mvnforum 附檔圖片縮放問題
本来贴到另一个帖子里的 为了大家找起来方便 再发个新贴吧
mvnforum原版对附件图片的尺寸大小是没有限制的,因此往往会出现图片尺寸太大撑坏版面的情况,以前在网上找到过一个js专门解决这个问题的贴上来与大家分享 具体解决方法:
用到的文件有viewthread.jsp,net.myvietnam.mvncore.filter.URLFilter
首先是只解决上传的图片大小缩放的问题找到 viewthread.jsp在head标记间加入下面这段js

<!--***********add by dyhjjk********************-->
<script language="javascript">
<!--
function resizeimg(ImgD,iwidth,iheight,desc) {
var image=new Image();
image.src=ImgD.src;
if(image.width>0 && image.height>0){
if(image.width/image.height>= iwidth/iheight){
if(image.width>iwidth){
ImgD.width=iwidth;
ImgD.height=(image.height*iwidth)/image.width;
}else{
ImgD.width=image.width;
ImgD.height=image.height;
}
ImgD.alt=image.width+""+image.height;
}
else{
if(image.height>iheight){
ImgD.height=iheight;
ImgD.width=(image.width*iheight)/image.height;
}else{
ImgD.width=image.width;
ImgD.height=image.height;
}
ImgD.alt=image.width+""+image.height;
}
ImgD.style.cursor= "pointer"; //??
ImgD.onclick = function() { window.open(this.src);} //????
if (navigator.userAgent.toLowerCase().indexOf("ie") > -1) { //жIE
ImgD.title = desc;
ImgD.onmousewheel = function img_zoom() //
{
var zoom = parseInt(this.style.zoom, 10) || 100;
zoom += event.wheelDelta / 12;
if (zoom> 0)this.style.zoom = zoom + "%";
return false;
}
} else { //IE
ImgD.title = desc;
}
}
}
-->
</script>
<!--***********add by dyhjjk********************-->

然后找到
<img src="<%=urlResolver.encodeURL(request, response, "getattachment?attach=" + attachBean.getAttachID(), URLResolver.ACTION_URL)%>" alt="<%=attachBean.getAttachFilename()%>" title="<%=attachBean.getAttachFilename()%>" border="0" >
这行 改成
<img src="<%=urlResolver.encodeURL(request, response, "getattachment?attach=" + attachBean.getAttachID(), URLResolver.ACTION_URL)%>" alt="<%=attachBean.getAttachFilename()%>" title="<%=attachBean.getAttachFilename()%>" border="0" onload="javascript:resizeimg(this,300,300,'<%=attachBean.getAttachFilename()%>')">
再就是针对链接图片的问题
这个需要改net.myvietnam.mvncore.filter.URLFilter
在代码里面找到 //process
然后改为
buf.append("\" border=\"0\" onload=javascript:resizeimg(this,300,300,'')>");
oldend = u2 + 6; // 6 == length of [/img]
重新生成myvietnam.jar包 覆盖网站中的myvietnam.jar就可以了
哈 终于完成了 测试下吧 有什么问题大家一起探讨
----------------------------------------
支持小惡魔
BTC : 19tn3RnCuwZVukXAwyhDWZD4uBgUZoGJPx
LTC : LTFa17pSvvoe3aU5jbmfcmEpo1xuGa9XeA
知識跟八卦一樣,越多人知道越有價值;知識最好的備份方法,散播!
藍色小惡魔(林永傑): 臉書