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;