Skip to content

Commit 77b7876

Browse files
committed
Video atom as main media in articles - image fix
1 parent bca8aa3 commit 77b7876

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
@@ -55,6 +55,7 @@ type Props = {
5555
byline?: string;
5656
showByline?: boolean;
5757
contentType?: string;
58+
contentLayout?: string;
5859
};
5960

6061
export const YoutubeBlockComponent = ({
@@ -97,6 +98,7 @@ export const YoutubeBlockComponent = ({
9798
byline,
9899
showByline,
99100
contentType,
101+
contentLayout,
100102
}: Props) => {
101103
const [consentState, setConsentState] = useState<ConsentState | undefined>(
102104
undefined,
@@ -115,13 +117,22 @@ export const YoutubeBlockComponent = ({
115117
*/
116118
const uniqueId = `${assetId}-${index}`;
117119

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

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 ||
@@ -889,6 +891,7 @@ export const renderElement = ({
889891
showTextOverlay={false}
890892
hidePillOnMobile={false}
891893
contentType={contentType}
894+
contentLayout={contentLayout}
892895
/>
893896
</Island>
894897
);
@@ -957,6 +960,7 @@ export const RenderArticleElement = ({
957960
isSectionedMiniProfilesArticle,
958961
shouldHideAds,
959962
contentType,
963+
contentLayout,
960964
}: Props) => {
961965
const withUpdatedRole = updateRole(element, format);
962966

@@ -984,6 +988,7 @@ export const RenderArticleElement = ({
984988
isSectionedMiniProfilesArticle,
985989
shouldHideAds,
986990
contentType,
991+
contentLayout,
987992
});
988993

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

0 commit comments

Comments
 (0)