From 5f4a0f2881b9420f3a3f3fb6527352f58a99d9ea Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 28 Nov 2024 23:29:45 +0000 Subject: "Contain" images with missing dimensions instead of cropping them (#6828) * Show unknown aspect as "contain" for autosize * Fix a flash of wrong position when opening in lightbox * Fix last frame flash on Android --- src/view/com/util/images/AutoSizedImage.tsx | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/view/com/util/images/AutoSizedImage.tsx') diff --git a/src/view/com/util/images/AutoSizedImage.tsx b/src/view/com/util/images/AutoSizedImage.tsx index 617b9bec4..a411b24bb 100644 --- a/src/view/com/util/images/AutoSizedImage.tsx +++ b/src/view/com/util/images/AutoSizedImage.tsx @@ -85,10 +85,6 @@ export function AutoSizedImage({ if (Number.isNaN(aspectRatio)) { aspectRatio = undefined } - } else { - // If we don't know it synchronously, treat it like a square. - // We won't use fetched dimensions to avoid a layout shift. - aspectRatio = 1 } let constrained: number | undefined @@ -103,11 +99,13 @@ export function AutoSizedImage({ const cropDisabled = crop === 'none' const isCropped = rawIsCropped && !cropDisabled + const isContain = aspectRatio === undefined const hasAlt = !!image.alt const contents = ( { - fetchedDimsRef.current = { - width: e.source.width, - height: e.source.height, + if (!isContain) { + fetchedDimsRef.current = { + width: e.source.width, + height: e.source.height, + } } }} /> -- cgit 1.4.1