1
I have an image that will be rendered in a Div, but I need to capture her Height because I need to treat it before putting it in the div (size). I don’t have the image on the screen, so I can’t do a Document.Getelement..
1
I have an image that will be rendered in a Div, but I need to capture her Height because I need to treat it before putting it in the div (size). I don’t have the image on the screen, so I can’t do a Document.Getelement..
1
Use the function below
var tmpImg = new Image();
tmpImg.src="https://www.google.com/intl/en_com/images/srpr/logo3w.png"; //or document.images[i].src;
$(tmpImg).one('load',function(){
orgWidth = tmpImg.width;
orgHeight = tmpImg.height;
alert(orgWidth+"x"+orgHeight);
});
Browser other questions tagged javascript jquery html
You are not signed in. Login or sign up in order to post.
Take a look at this link, it might be useful, https://stackoverflow.com/questions/6575159/get-image-dimensions-with-javascript-before-image-has-fully-loaded
– N. Dias
Oops! Thanks , it was very close that Guilherme posted here below.. and it worked! Thanks!
– Thiago Loureiro