marwinious
10/22/2013 - 4:45 PM

jQuery: Get image dimensions before loading. From http://stackoverflow.com/questions/6124409/image-size-before-is-in-dom

jQuery: Get image dimensions before loading. From http://stackoverflow.com/questions/6124409/image-size-before-is-in-dom

var imgLoad = $("<img />");
imgLoad.attr("src", ImageGallery.ImagesList[index] + "?" + new Date().getTime());
imgLoad.unbind("load");
imgLoad.bind("load", function () {

   // Get image sizes
   alert(this.width);

});