1、htmer_img.js文件放到网站内
ResizeImage 缩放宽度
ResizeImage2 缩放高度
function ResizeImage(objImage,swidth,sheight,maxWidth){
//三个参数 需满足高度和宽度再进行图片缩放,防止广告位高度宽度不足引起的误缩放
//swidth 满足缩放的宽度
//sheight 满足缩放的高度
//maxWidth将来图片缩放的宽度
try{
if(maxWidth>0){
if(objImage.width>swidth&&objImage.height>sheight){
objImage.width=maxWidth;
if (window.attachEvent)
{objImage.attachEvent('onclick', function(){try{window.open(objImage.src);}catch(e){window.open(objImage.src);}});
objImage.attachEvent('onmouseover', function(){objImage.style.cursor='pointer';});
}
if (window.addEventListener)
{objImage.addEventListener('click', function(){try{window.open(objImage.src);}catch(e){window.open(objImage.src);}},false);
objImage.addEventListener('mouseover', function(){objImage.style.cursor='pointer';},false);
}
}
}
}catch(e){};
}
function ResizeImage2(objImage,swidth,sheight,maxHeight){
//三个参数 需满足高度和宽度再进行图片缩放,防止广告位高度宽度不足引起的误缩放
//swidth 满足缩放的宽度
//sheight 满足缩放的高度
//maxWidth将来图片缩放的高度
try{
if(maxHeight>0){
if(objImage.width>swidth&&objImage.height>sheight){
objImage.height=maxHeight;
if (window.attachEvent)
{objImage.attachEvent('onclick', function(){try{window.open(objImage.src);}catch(e){window.open(objImage.src);}});
objImage.attachEvent('onmouseover', function(){objImage.style.cursor='pointer';});
}
if (window.addEventListener)
{objImage.addEventListener('click', function(){try{window.open(objImage.src);}catch(e){window.open(objImage.src);}},false);
objImage.addEventListener('mouseover', function(){objImage.style.cursor='pointer';},false);
}
}
}
}catch(e){};
}
2、网站内容模板<head></head>增加,注意引用路径,如果JS放在根目录或SKIN下面
<script language="JavaScript" src="htmer_img.js" type="text/javascript"></script>
3、使用时手动可以在img增加onload 如下,如自动,则进行第4,5步骤操作
<img onload="ResizeImage(this,400,300,200);"
共4个参数,
第1个参数为固定
第2个参数为大于多大宽度
第3个参数为大于多高
第4个参数为等比例缩放最大宽度
其中200为等比例缩放宽度,大于400的图片和大于300高度的图片全部缩,防止某些广告位宽度够也被误缩
4、修改CMS的内容模板 注意看配置到几,同时修改第6步
模板8配置 是否启用自动缩放图片 0不启用1启用
模板9配置 onload='ResizeImage(this,400,300,200);'
或 onload='ResizeImage2(this,400,300,200);'
5、修改CMS程序inc/NewsChannel.asp修改ContentPagination()
在strContent = enchiasp.ReadContent(Rs("Content"))下方增加
strContent = Replace(strContent, "<img", "<img {$zidongsuofang}")
6、在inc下/NewsChannel.asp修改
ReadArticleContent(ArticleID, CurrentPage)
在HtmlContent = enchiasp.HtmlContent下方增加
if enchiasp.HtmlSetting(8)=0 then
ArticleContent = Replace(ArticleContent, "{$zidongsuofang}", "")
else
ArticleContent = Replace(ArticleContent, "{$zidongsuofang}", enchiasp.HtmlSetting(9))
end if
ArticleContent = Replace(ArticleContent, "{$zidongsuofang}", "")