第一步:在img加上便签,还要去掉height属性。

修改内容页模板的{dede:field.body /}为

<span style="font-family:tahoma,geneva,sans-serif;"><span style="font-size:14px;">{dede:field.body runphp='yes'}
$content = @me;
$mode1 = "/<img/";
$mode2 = "/height=\"(\d+)\" /";
$str1 = "<img onload=\"javascript:ImgReSize(this)\"";
$content = preg_replace($mode1,$str1,$content);
$content = preg_replace($mode2,"",$content);
@me = $content;
{/dede:field.body}</span></span>

第二步:将下面代码插入到<head></head>中。

注意那个670的数值,这个值意思是当图片超过这个数值,自动将图片缩小,宽度缩小为670,高度自动按比例缩小,这样不会变型。

<span style="font-family:tahoma,geneva,sans-serif;"><span style="font-size:14px;"><script language='javascript'>
function ImgReSize(e)
{
if(e.width>670) // 670可根据你文章的内容区域大小,可调整
{
e.width=670; // 等同上面你设的那个数值
e.style.;
}
if(e.height>10)
{
e.style.;
}
}
</script></span></span>
历史上的今天
01月
10
    抱歉,历史上的今天作者很懒,什么都没写!
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。