See: #301 (comment)
The problem here is that the image is rendered conditionally, so when the user first clicks the button, the image is not yet loaded, so the browser doesn't know yet how big it will be. The max-width and aspect-ratio CSS rules don't help, since the image might be smaller than that. After that, the image is cached so the browser will tell us the correct height.