Skip to content

Commit e6783cf

Browse files
authored
Merge pull request #14300 from guardian/rjr-fix-video-main-media-poster-images
Video atom as main media in articles - poster image fix
2 parents 6d4f14d + 82aef30 commit e6783cf

File tree

4 files changed

+23
-3
lines changed

4 files changed

+23
-3
lines changed

dotcom-rendering/src/components/MainMedia.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ type Props = {
8989
editionId: EditionId;
9090
shouldHideAds: boolean;
9191
contentType?: string;
92+
contentLayout?: string;
9293
};
9394

9495
export const MainMedia = ({
@@ -107,6 +108,7 @@ export const MainMedia = ({
107108
editionId,
108109
shouldHideAds,
109110
contentType,
111+
contentLayout,
110112
}: Props) => {
111113
return (
112114
<div css={[mainMedia, chooseWrapper(format)]}>
@@ -131,6 +133,7 @@ export const MainMedia = ({
131133
editionId={editionId}
132134
shouldHideAds={shouldHideAds}
133135
contentType={contentType}
136+
contentLayout={contentLayout}
134137
/>
135138
))}
136139
</div>

dotcom-rendering/src/components/YoutubeBlockComponent.importable.tsx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ type Props = {
5454
byline?: string;
5555
showByline?: boolean;
5656
contentType?: string;
57+
contentLayout?: string;
5758
};
5859

5960
export const YoutubeBlockComponent = ({
@@ -95,6 +96,7 @@ export const YoutubeBlockComponent = ({
9596
byline,
9697
showByline,
9798
contentType,
99+
contentLayout,
98100
}: Props) => {
99101
const [consentState, setConsentState] = useState<ConsentState | undefined>(
100102
undefined,
@@ -113,13 +115,22 @@ export const YoutubeBlockComponent = ({
113115
*/
114116
const uniqueId = `${assetId}-${index}`;
115117

116-
// We need Video articles generated directly from Media Atom Maker
117-
// to always show their poster (16:9) image, but in other cases
118-
// use the override image (often supplied as 5:4 then cropped to 16:9)
119118
const getPosterImage = () => {
119+
// We need Video articles generated directly from Media Atom Maker
120+
// to always show their poster (16:9) image, but in other cases
121+
// use the override image (often supplied as 5:4 then cropped to 16:9)
120122
if (contentType && contentType.toLowerCase() === 'video') {
121123
return posterImage;
122124
}
125+
126+
// For Standard Articles with a Video atom for their main media
127+
// we need to display the poster image
128+
if (contentLayout && contentLayout.toLowerCase() === 'standardlayout') {
129+
return posterImage;
130+
}
131+
132+
// Default behaviour is to use the override image, if supplied
133+
// otherwise use the poster image
123134
return overrideImage ?? posterImage;
124135
};
125136

dotcom-rendering/src/layouts/StandardLayout.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,7 @@ export const StandardLayout = (props: WebProps | AppProps) => {
519519
hideCaption={isMedia}
520520
shouldHideAds={article.shouldHideAds}
521521
contentType={article.contentType}
522+
contentLayout="StandardLayout"
522523
/>
523524
</div>
524525
</GridItem>

dotcom-rendering/src/lib/renderElement.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ type Props = {
9797
isSectionedMiniProfilesArticle?: boolean;
9898
shouldHideAds: boolean;
9999
contentType?: string;
100+
contentLayout?: string;
100101
};
101102

102103
// updateRole modifies the role of an element in a way appropriate for most
@@ -159,6 +160,7 @@ export const renderElement = ({
159160
isSectionedMiniProfilesArticle = false,
160161
shouldHideAds,
161162
contentType,
163+
contentLayout,
162164
}: Props) => {
163165
const isBlog =
164166
format.design === ArticleDesign.LiveBlog ||
@@ -888,6 +890,7 @@ export const renderElement = ({
888890
iconSizeOnMobile="large"
889891
hidePillOnMobile={false}
890892
contentType={contentType}
893+
contentLayout={contentLayout}
891894
/>
892895
</Island>
893896
);
@@ -956,6 +959,7 @@ export const RenderArticleElement = ({
956959
isSectionedMiniProfilesArticle,
957960
shouldHideAds,
958961
contentType,
962+
contentLayout,
959963
}: Props) => {
960964
const withUpdatedRole = updateRole(element, format);
961965

@@ -983,6 +987,7 @@ export const RenderArticleElement = ({
983987
isSectionedMiniProfilesArticle,
984988
shouldHideAds,
985989
contentType,
990+
contentLayout,
986991
});
987992

988993
const needsFigure = !bareElements.has(element._type);

0 commit comments

Comments
 (0)