Possible Duplicate:
Javascript – Function to return width/height of remote image from url
Is it possible to get width and height by just knowing the images location with js? The actual picture isn’t loaded onto the DOM. I have been trying this with jQuery but with no luck yet.
var img = $('<img>').attr('src', 'images/logo.png');
console.log($(img).width());
returns 0.
No, the image doesn’t need to be in the DOM.
But you have to load it before knowing its dimensions
(note the src after the onload function)
here is a jsfiddle : http://jsfiddle.net/fGUyz/2/
#NotMrDownVoter