From feface11c1e64e09b4436be43d91df56e2751f60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?nicole=20miko=C5=82ajczyk?= Date: Sat, 17 Jan 2026 23:27:50 +0100 Subject: [PATCH] pl-fe: fix missing aspect ratio case when height and width is provided MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: nicole mikołajczyk --- packages/pl-fe/src/components/media-gallery.tsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/pl-fe/src/components/media-gallery.tsx b/packages/pl-fe/src/components/media-gallery.tsx index ce00867ca..d4d6c4bee 100644 --- a/packages/pl-fe/src/components/media-gallery.tsx +++ b/packages/pl-fe/src/components/media-gallery.tsx @@ -40,8 +40,15 @@ interface SizeData { itemsDimensions: Dimensions[]; } -const getAspectRatio = (attachment: MediaAttachment) => - (attachment.type === 'gifv' || attachment.type === 'image' || attachment.type === 'video') && attachment.meta.original?.aspect || null; +const getAspectRatio = (attachment: MediaAttachment) => { + if ((attachment.type === 'gifv' || attachment.type === 'image' || attachment.type === 'video') && attachment.meta.original) { + if (attachment.meta.original.aspect) { + return attachment.meta.original.aspect; + } + return attachment.meta.original.width / attachment.meta.original.height; + } + return null; +}; const withinLimits = (aspectRatio: number) => aspectRatio >= minimumAspectRatio && aspectRatio <= maximumAspectRatio;