This seems like quite a rudimentary issue, but no matter how I phrase it, I can't seem to find anyone who's got a solution for me.
I have an image that's set size to fit my layout and to retain its aspect ratio, like so:
Make sure that your image is already loaded to get correct value. For this, either use
load event of
window instead of
DOMContentLoaded event of
ready in jQuery), or preload your image via JS.