One, background
1, the background datasheet in the design, for each picture, there is no record of its width and height of the pixel value.
2, picture width and height have different size, for example, a type of picture is 700*500 pixels, B type of picture is 700*1000 Pixel
3, in the foreground there is a 700*500 pixel of a fixed size picture display area, used to display a variety of size pictures
4, a type of picture normal display, B type of graph limit high display, that is, displayed as a 350*500 pixel
5, can not use other fields to distinguish between a-type picture and B-type pictures (if you are designing a datasheet when the width and height of the picture should be recorded ...).
Two, workaround
you need to use JS in the foreground based on the image width and height of the pixel value, to determine whether the picture is a type A or B type.
Consider using AJAX to load asynchronously, calculate the pixel values for width and height after the picture has been successfully loaded, and then set the width and height properties of the picture in the HTML img tag. The
code is as follows:
/** The pixel value of the width and height of the picture dynamically * * @param surl the URL * of the picture @param fcallback callback function, fcallback at least one parameter of type Object type is used to receive the picture's width, height, url * * USAG E: * var url = "Http://mat1.gtimg.com/datalib_img//11-05-26/c/c21ff1138e7349859b49b99312d05baf.jpg"; * FGETIMG (URL, Function (IMG) {alert (' Width: ' +img.width+ '; height: "+img.height+"; URL: "+img.url);}"; * */var fgetimg = function (sURL, fcallback) {var img = new Image (); img.src = sURL + '? t= ' + math.random ()//ie, Ajax will slow down Saves, causing the onreadystatechange function to not be triggered, so you need to add a random number if (Fbrowser.isie) {img.onreadystatechange = function () {if (this.readystate = = "Loaded" | | this.readystate== "complete") {Fcallback ({width:img.width, height:img.height, Url:surl});}; }else if (Fbrowser.isfirefox | | Fbrowser.issafari | | Fbrowser.isopera | | Fbrowser.ischrome) {img.onload = function () {Fcallback ({width:img.width, height:img.height, Url:surl});};} else {fcal Lback ({width:img.width, height:img.height, url:surl}); } };