Capturing Attributes from an Image with JavaScript or JQuery via Url

1

I have an image that will be rendered in a Div, but I need to capture the Height of it since I need to deal with it before putting it in the div (size). I do not have the image on the screen, so I can not make a document.GetElement ..

    
asked by anonymous 28.11.2017 / 16:23

1 answer

1

Use the function below

var tmpImg = new Image();
tmpImg.src="https://www.google.com/intl/en_com/images/srpr/logo3w.png";//ordocument.images[i].src;$(tmpImg).one('load',function(){orgWidth=tmpImg.width;orgHeight=tmpImg.height;alert(orgWidth+"x"+orgHeight);
});
    
28.11.2017 / 16:26