That sounds like a problem that should be fixed in CSS. Ideally, it should be possible to specify that an image should have a width and/or max-width of 100vw, 100% of its parent, or whatever, taking box-sizing and paddings into account... and then specify that its height should be a certain percentage of its own width. The server already knows the aspect ratio, so it can deliver this information in a 'style' attribute.
I haven't been following the latest developments in CSS for a while, so maybe it's already possible to do this?
I do this in production a few places by setting a div with no content or only absolutely position content to have padding-bottom of the aspect ratio in %. That gets calculated from the width, so if the image is 4:3 my ratio is 75%; 200px wide becomes 150px tall as well. Then, I set the image as a background to the div or absolutely position it inside to fill the space, and it's responsive to the layout while also reserving space for itself.
I haven't been following the latest developments in CSS for a while, so maybe it's already possible to do this?