determine width and height of an image while it isn't inserted to the dom
I'm receiving images inside a long string from a server using an ajax call
The url of the image is inside result[1] for sure. I've used
width/naturalWidth and height/naturalHeight and on occasion they return 0
and in other cases they return the right size in pixels
var imgElement = jQuery("<img>").attr("src", result[1]);
var width = imgElement[0].naturalWidth;
var height = imgElement[0].naturalHeight;
if (width >= that.minImgPixels && height >= that.minImgPixels) {
image = result[1];
}
How is the right way to check image width and height without inserting it
to the dom?
No comments:
Post a Comment