pl-fe: fix missing aspect ratio case when height and width is provided

Signed-off-by: nicole mikołajczyk <git@mkljczk.pl>
This commit is contained in:
nicole mikołajczyk
2026-01-17 23:27:50 +01:00
parent f87639e75a
commit feface11c1

View File

@ -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;