I am creating a jQuery plugin.
How do I get the real image width and height with Javascript in Safari?
The following works with Firefox 3, IE7 and Opera 9:>
Use the naturalHeight and naturalWidth attributes from HTML5.
naturalHeight
naturalWidth
For example:
var h = document.querySelector('img').naturalHeight;
Works in IE9+, Chrome, Firefox, Safari and Opera (stats).