I edited the template (a custom version of prosilver) and added in attachment.html loading="lazy"
That really improves performance - but has an annoying side effect. when you scroll down (e.g., to #unread), it takes a while for the images to catch up, causing the scroll position to shift.
Indeed, the browser would have to know the size of the image that isn't being displayed yet, in order to know how much real estate to reserve within the page.
Maybe someone knows of the smarter or more modern method, but so far as I know, you would have to change phpBB to use image horizontal and vertical size data of each image attachment to render the <img> tags with a specific height= and width= attribute, in addition to the lazy load processing. Such that even when the <img> tags are still "blank", they already require the same amount of horizontal and vertical room the displayed image will also eventually require.
That seems like it would require an extension on both points: Making best effort to determine accurate image dimensions for the thumbnail or attachment to be displayed, and then modifying the rendered <img> tags to include the specific height= and width= attributes.