The function gets the element, takes the src
property from it, and now we have the usual link to the image. How to find out its original size?
|
1 answer
From the Internet
function getImgSize(imgSrc) { var newImg = new Image(); newImg.onload = function() { var height = newImg.height; var width = newImg.width; console.log('The image size is '+width+'*'+height); } newImg.src = imgSrc; // this must be done AFTER setting onload }
Using getImgSize ($ ('img'). Attr ('src'))
- thanks, but I didn’t find it myself :( - stck
|