Is there a simple and efficient way to get the true dimensions (in JavaScript) of an image that is displayed in an <img> element with a potentially different rendered size (e.g. via max-height or max-width)?
Is there a simple and efficient way to get the true dimensions (in JavaScript)
Share
There is present
naturalWidthandnaturalHeightDOM attributes.For example:
Or see example on jsFiddle.
More info at MDN