Get real image width and height with Javascript in Safari/Chrome?
        Posted  
        
            by Frank Bannister
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Frank Bannister
        
        
        
        Published on 2008-11-25T19:44:38Z
        Indexed on 
            2010/03/16
            11:36 UTC
        
        
        Read the original article
        Hit count: 345
        
I am creating a jQuery plugin.
How do I get real image width and height with Javascript in Safari?
Following works with Firefox 3, IE7 and Opera 9:
var pic = $("img")
// need to remove these in of case img-element has set width and height
pic.removeAttr("width"); 
pic.removeAttr("height");
var pic_real_width = pic.width();
var pic_real_height = pic.height();
But in Webkit browsers like Safari and Google Chrome values are 0...
Doing this on server side is not an option.
© Stack Overflow or respective owner