Get the real width and height of an image with JavaScript? (in Safari/Chrome)
Webkit browsers set the height and width property after the image is loaded. Instead of using timeouts, I’d recommend using an image’s onload event. Here’s a quick example: var img = $(“img”)[0]; // Get my img elem var pic_real_width, pic_real_height; $(“<img/>”) // Make in memory copy of image to avoid css issues .attr(“src”, $(img).attr(“src”)) .load(function() … Read more