@@ -25,7 +25,7 @@ import {
2525} from '../lib/video' ;
2626import { palette } from '../palette' ;
2727import type { RoleType } from '../types/content' ;
28- import type { VideoPlayerFormat } from '../types/mainMedia' ;
28+ import type { AspectRatio , VideoPlayerFormat } from '../types/mainMedia' ;
2929import type { RenderingTarget } from '../types/renderingTarget' ;
3030import { Caption } from './Caption' ;
3131import { CardPicture , type Props as CardPictureProps } from './CardPicture' ;
@@ -185,15 +185,18 @@ const dispatchOphanAttentionEvent = (
185185 document . dispatchEvent ( event ) ;
186186} ;
187187
188- const getOptimisedPosterImage = ( mainImage : string ) : string => {
188+ const getOptimisedPosterImage = (
189+ mainImage : string ,
190+ aspectRatio : string ,
191+ ) : string => {
189192 // This only runs on the client
190193 const resolution = window . devicePixelRatio >= 2 ? 'high' : 'low' ;
191194
192195 return generateImageURL ( {
193196 mainImage,
194197 imageWidth : 940 , // The widest a video can be: flexible special container, giga-boosted slot
195198 resolution,
196- aspectRatio : '5:4' ,
199+ aspectRatio,
197200 } ) ;
198201} ;
199202
@@ -284,7 +287,7 @@ type Props = {
284287 atomId : string ;
285288 uniqueId : string ;
286289 videoStyle : VideoPlayerFormat ;
287- aspectRatio : number ;
290+ aspectRatio : AspectRatio ;
288291 posterImage : string ;
289292 fallbackImage : CardPictureProps [ 'mainImage' ] ;
290293 fallbackImageSize : CardPictureProps [ 'imageSize' ] ;
@@ -880,13 +883,15 @@ export const SelfHostedVideo = ({
880883
881884 /** The aspect ratio of the video will be clamped within the specified range */
882885 const aspectRatioOfVisibleVideo = getAspectRatioOfVisibleVideo (
883- aspectRatio ,
886+ aspectRatio . numberRepresentation ,
884887 minAspectRatio ,
885888 maxAspectRatio ,
886889 ) ;
887890
888- const isVideoCroppedAtTopBottom = aspectRatio < aspectRatioOfVisibleVideo ;
889- const isVideoCroppedAtLeftRight = aspectRatio > aspectRatioOfVisibleVideo ;
891+ const isVideoCroppedAtTopBottom =
892+ aspectRatio . numberRepresentation < aspectRatioOfVisibleVideo ;
893+ const isVideoCroppedAtLeftRight =
894+ aspectRatio . numberRepresentation > aspectRatioOfVisibleVideo ;
890895
891896 const isGreyBarsAtSidesOnDesktop =
892897 containerAspectRatioDesktop !== undefined &&
@@ -899,7 +904,7 @@ export const SelfHostedVideo = ({
899904 const AudioIcon = isMuted ? SvgAudioMute : SvgAudio ;
900905
901906 const optimisedPosterImage = showPosterImage
902- ? getOptimisedPosterImage ( posterImage )
907+ ? getOptimisedPosterImage ( posterImage , aspectRatio . stringRepresentation )
903908 : undefined ;
904909
905910 return (
@@ -922,7 +927,7 @@ export const SelfHostedVideo = ({
922927 >
923928 < div
924929 css = { figureStyles (
925- aspectRatio ,
930+ aspectRatio . numberRepresentation ,
926931 aspectRatioOfVisibleVideo ,
927932 isGreyBarsAtSidesOnDesktop ,
928933 isGreyBarsAtTopAndBottomOnDesktop ,
@@ -935,7 +940,7 @@ export const SelfHostedVideo = ({
935940 sources = { optimisedSources }
936941 atomId = { atomId }
937942 uniqueId = { uniqueId }
938- aspectRatio = { aspectRatio }
943+ aspectRatio = { aspectRatio . numberRepresentation }
939944 width = { width }
940945 height = { height }
941946 videoStyle = { videoStyle }
0 commit comments