View Full Version : Finding out the size of an image without displaying it / inserting it into the dom

17 Oct 2010, 3:34 PM
Is there a way to find out the dimensions of an image before it is actually inserted into the dom tree? I tried creating an Ext.Element and installing an event handler to it without inserting it into the dom but that caused the following error: Uncaught Error listening for "load". Element "undefined" doesn't exist.
Is it possible at all or am I trying to do something incredibly stupid again? :-)

Thanx in advance

17 Oct 2010, 4:10 PM
Found a simple standard javascript solution:

var img = new Image();
img.onload = function() { callback(par1, par2, ...); };
img.src = 'path';

Better solutions / suggestions are appreciated.