I have an image tag with the width and height set:
<img src='<%#Eval("ImageLocation").ToString().TrimStart(new char[]{'~'}).ToLower() %>' width="147px" height="147px" />
Now some images are not 147x147 meaning they look not good, so I want to check the width and height of the image after load. I tried adding the onload on the img
<img src='<%#Eval("ImageLocation").ToString().TrimStart(new char[]{'~'}).ToLower() %>' width="147px" height="147px" onload="checkOrientation(this);"/>
and in the function I do :
function checkOrientation(el) {
alert(el.width + " " + el.height);
if (el.height < el.width)
$(el).removeAttr('height');
else
$(el).removeAttr('width');
}
but this always gives the 147 back, even if the picture not 147.
How can I get the width and height of the actual loaded image?