The code copy is as follows:
<div id=article><img src="/down/js/images/12498880470.jpg" /></div>
<script type="text/javascript" >
//Scale the image to the appropriate size
function ResizeImages()
{
var myimg, oldwidth, oldheight;
var maxwidth=550;
var maxheight=880
var imgs = document.getElementById('article').getElementsByTagName('img'); //If the id you define is not an article, please modify it here
for(i=0;i<imgs.length;i++){
myimg = imgs[i];
if(myimg.width > myimg.height)
{
if(myimg.width > maxwidth)
{
oldwidth = myimg.width;
myimg.height = myimg.height * (maxwidth/oldwidth);
myimg.width = maxwidth;
}
}else{
if(myimg.height > maxheight)
{
oldheight = myimg.height;
myimg.width = myimg.width * (maxheight/oldheight);
myimg.height = maxheight;
}
}
}
}
//Scale the picture to the appropriate size
ResizeImages();
</script>
It means to control the size of the image in the specified area, otherwise some larger advertising images will also deform.
The picture control code used by Wulin.com:
The code copy is as follows:
function controlImg(ele,w,h){
var c=ele.getElementsByTagName("img");
for(var i=0;i<c.length;i++){
var w0=c[i].clientWidth,h0=c[i].clientHeight;
var t1=w0/w,t2=h0/h;
if(t1>1||t2>1||w0>=600){
c[i].width=Math.floor(w0/(t1>t2?t1:t2));
c[i].height=Math.floor(h0/(t1>t2?t1:t2));
if(document.all){
c[i].outerHTML='<a href="'+c[i].src+'" target="_blank">'+c[i].outerHTML+'</a>'
}
else{
c[i].title="Open picture in new window";
c[i].onclick=function(e){window.open(this.src)}
}
}
}
}
ele is the specified area, w is the maximum width, and it will be reduced if it is greater than this. h is the maximum height.