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:>
This works cross browser
var img = new Image(); $(img).bind('load error', function(e) { $.data(img, 'dimensions', { 'width': img.width, 'height': img.height }); }); img.src = imgs[i];
get the dimensions by using
$(this).data('dimensions').width; $(this).data('dimensions').height;
Cheers!