How to get the original size of an image -Jquery
<p><strong>SOLVED</strong>: Syntax-Error</p>

<p>the following code works:</p>

<pre><code>var image = {width:0,heigth:0};
var imageObject = new Image();
function getImageSize(id) {
    imageObject.src = id.attr("src");
    image.width = imageObject.width;
    image.heigth = imageObject.heigth;
}
</code></pre>

<p><strong>Question was:</strong></p>

<p>I want to get the original width and height of an image and tried different code to achieve it. My function triggers on click event and all images are resized to 400x300.</p>

<p>I tried to resize the Image to its original size by using 'auto'</p>

<pre><code>var image = {width:0,heigth:0};
function getImageSize(id) {
    id.css({
        'width': 'auto',
        'heigth': 'auto'
    });
    image.width = id.attr('width');
    image.heigth = id.attr('heigth');
}
</code></pre>

<p>attaching 'auto' didn't change the size of the image</p>

<p>alert(id.attr('width')); always returns 'undefined'. so it doesn't work</p>

<pre><code>var image = {width:0,heigth:0};
var imageObject = new Image();
function getImageSize(id) {
    imageObject.src = id.attr("src");
    image.width = imageObject.width;
    image.heigth = imageObject.heigth;
}
</code></pre>

<p>alert(image.width); works perfectly</p>

<p>alert(image.heigth); returns undefined</p>

<p>using imageObject.naturalWidth works as the one above - the width is given correctly but the heigth is undefined</p>

<p>I read that you have to append the new image object, but when I use imageObject.appendTo('body'); I can't even click the image.</p>

<p>Thanks for any suggestions.</p>
