Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
thumbnail_galleries: Placehold with aspect-ratio.
Karl Stolley72b236723df3
diff --git a/web/src/postprocess_content.ts b/web/src/postprocess_content.tsindex 93564604bf5..e4c59022724 100644--- a/web/src/postprocess_content.ts+++ b/web/src/postprocess_content.ts@@ -320,6 +320,18 @@ export function postprocess_content(html: string): string {`${(image_box_em * original_width) / original_height}em`,);+ // To avoid a layout shift especially on portrait images, we+ // set the `aspect-ratio`, which flexbox respects and will+ // therefore preserve exactly the correct amount of space+ // prior to the image loading.+ // TODO: Correct our unit tests to not discard `aspect-ratio`;+ // should that property be recognized, there will be test+ // failures all over the place in `postprocess_content.test.cjs`+ message_media_image.style.setProperty(+ "aspect-ratio",+ `${original_width / original_height}`,+ );+if (is_dinky_image) {message_media_image.classList.add("dinky-thumbnail");// For dinky images, we just set the original width