If you look under the hood, you find Vuetify uses the background image of a DIV
element, and not an IMG
element. If you then take apart the engine, you find the natural width and aspect ratio stashed in the Vue component.
I needed to extract this in a pinch, so I did the following. I'm not recommending this non-API hack, but "it is what it is".
I was not able to access the Component from my code, so needed to grab the dimensions from the element proper.
const naturalWidth = divElement.__vue__.naturalWidth
const naturalHeight = naturalWidth / divElement.__vue__.computedAspectRatio
You can also check your element is a v-img
, and get the html image element from the component
if (divElement.classList.contains('v-image')) {
const img = divElement.__vue__?.image as HTMLImageElement
if (img?.complete) {
process(img.naturalWidth, img.naturalHeight)
}
}
Finally, make sure you wait for the loaded
event.