主题: 关于kindsoft在IE7下面本地图片无法预览的解决方法
作者: Chaos, 发布日期: 2007-08-17 11:01:35, 浏览数: 7592
由于IE7的限制,本地图片无法用以前的方法预览了,我找了些资料,发现可以用滤镜来解决,解决方法如下:
更改KindEditor.js 789行的KindImagePreview函数如下:
function KindImagePreview()
{
var type = KE_IMAGE_DOCUMENT.getElementById('imageType').value;
var url = KE_IMAGE_DOCUMENT.getElementById('imgLink').value;
var file = KE_IMAGE_DOCUMENT.getElementById('imgFile').value;
if (type == 1) {
if (KE_BROWSER != 'IE') {
return false;
}
if (file == '') {
alert(KE_LANG['SELECT_IMAGE']);
return false;
}
url = 'file:///' + file;
if (KindCheckImageFileType(url, "\\") == false) {
return false;
}
} else {
if (KindCheckImageFileType(url, "/") == false) {
return false;
}
}
var el = KE_IMAGE_DOCUMENT.getElementById('imgPreview');
if (el.hasChildNodes()) {
el.removeChild(el.childNodes[0]);
}
if(type==1){
var imgObj = KE_IMAGE_DOCUMENT.createElement("div");
imgObj.style.width="230px";
imgObj.style.height="230px";
imgObj.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=imgae );";
el.appendChild(imgObj);
imgObj.filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src = url;
var width=imgObj.offsetWidth;
var height=imgObj.offsetHeight;
KE_IMAGE_DOCUMENT.getElementById('imgWidth').value = width;
KE_IMAGE_DOCUMENT.getElementById('imgHeight').value = height;
if (width<300 && height<300){
imgObj.filters.item("DXImageTransform.Microsoft.AlphaImageLoader").sizingMethod = 'crop';
}else{
imgObj.filters.item("DXImageTransform.Microsoft.AlphaImageLoader").sizingMethod = 'scale';
}
}else{
var imgObj = KE_IMAGE_DOCUMENT.createElement("IMG");
imgObj.src = url;
var width = parseInt(imgObj.width);
var height = parseInt(imgObj.height);
KE_IMAGE_DOCUMENT.getElementById('imgWidth').value = width;
KE_IMAGE_DOCUMENT.getElementById('imgHeight').value = height;
var rate = parseInt(width/height);
if (width >230 && height <= 230) {
width = 230;
height = parseInt(width/rate);
} else if (width <=230 && height > 230) {
height = 230;
width = parseInt(height*rate);
} else if (width >230 && height > 230) {
if (width >= height) {
width = 230;
height = parseInt(width/rate);
} else {
height = 230;
width = parseInt(height*rate);
}
}
imgObj.style.width = width;
imgObj.style.height = height;
el.appendChild(imgObj);
}

return imgObj;
}
发表新帖 发表回复