Skip to content

Commit 9a4e78a

Browse files
committed
Set containerAspectRatio
1 parent 94786fd commit 9a4e78a

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

dotcom-rendering/src/components/LoopVideoInArticle.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,17 @@ export const LoopVideoInArticle = ({
2929
return null;
3030
}
3131

32+
const calculateAspectRatio = (): number => {
33+
const dimensions = firstVideoAsset?.dimensions;
34+
35+
if (dimensions) {
36+
return dimensions.width / dimensions.height;
37+
}
38+
39+
// Default aspect ratio if dimensions are not available
40+
return 5 / 4;
41+
};
42+
3243
return (
3344
<>
3445
<Island priority="critical" defer={{ until: 'visible' }}>
@@ -39,6 +50,7 @@ export const LoopVideoInArticle = ({
3950
fallbackImageAspectRatio={
4051
(firstVideoAsset?.aspectRatio ?? '5:4') as FEAspectRatio
4152
}
53+
containerAspectRatio={calculateAspectRatio()}
4254
fallbackImageLoading="lazy"
4355
fallbackImageSize="small"
4456
height={firstVideoAsset?.dimensions?.height ?? 400}

0 commit comments

Comments
 (0)