FIX: Ensure images in polls don't cause abrupt scrolling (PR #13272)

In some very rare cases, poll options can end up with images that have no dimensions, in which case, navigating to replies in that post stream might result in unexpected scrolling (as the browser loads the images and adjusts its layout).

This ensures that if width/height attributes are missing from an image, the image is forced to display at a height of 200 pixels.

GitHub

Is the width fixed somewhere as well? I don’t think the max-width above is enough to prevent jumping?

This will select elements where the width is missing AND the height is missing.

I think we should select elements where the width is missing OR the height is missing. The browser needs both in order to calculate the aspect ratio.

    &:not([width]), &:not([height]) {

In my testing, only the height was necessary. Regardless of the width, the browser will reserve that specific height for the asset. And as far as scrolling is concerned, only the height is important.

I think not setting width also means that an image with width=500 and height=200 won’t need to be shrunk to fit a 200x200 box.

And as far as scrolling is concerned, only the height is important.

Unfortunately the width also matters, because a wider image can force other elements (e.g. text) to wrap, thereby taking up more height.

Right, I hadn’t thought of inline images. Ok let’s try setting width too.