Skip to content

Commit 941cffe

Browse files
committed
Add support for Cinemagraphs in articles
1 parent f4af771 commit 941cffe

File tree

2 files changed

+14
-17
lines changed

2 files changed

+14
-17
lines changed

dotcom-rendering/src/components/LoopVideoInArticle.tsx renamed to dotcom-rendering/src/components/SelfHostedVideoInArticle.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,24 @@ import {
66
getSubtitleAsset,
77
} from '../lib/video';
88
import type { MediaAtomBlockElement } from '../types/content';
9+
import type { VideoPlayerFormat } from '../types/mainMedia';
910
import { Caption } from './Caption';
1011
import { Island } from './Island';
1112
import { SelfHostedVideo } from './SelfHostedVideo.importable';
1213

13-
type LoopVideoInArticleProps = {
14+
type SelfHostedVideoInArticleProps = {
1415
element: MediaAtomBlockElement;
1516
format: ArticleFormat;
1617
isMainMedia: boolean;
18+
videoStyle: VideoPlayerFormat;
1719
};
1820

19-
export const LoopVideoInArticle = ({
21+
export const SelfHostedVideoInArticle = ({
2022
element,
2123
format,
2224
isMainMedia,
23-
}: LoopVideoInArticleProps) => {
25+
videoStyle,
26+
}: SelfHostedVideoInArticleProps) => {
2427
const posterImageUrl = element.posterImage?.[0]?.url;
2528
const caption = element.title;
2629
const firstVideoAsset = getFirstVideoAsset(element.assets);
@@ -59,7 +62,7 @@ export const LoopVideoInArticle = ({
5962
sources={convertAssetsToVideoSources(element.assets)}
6063
subtitleSize="medium"
6164
subtitleSource={getSubtitleAsset(element.assets)}
62-
videoStyle="Loop"
65+
videoStyle={videoStyle}
6366
uniqueId={element.id}
6467
width={firstVideoAsset?.dimensions?.width ?? 500}
6568
enableHls={false}

dotcom-rendering/src/lib/renderElement.tsx

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import { Island } from '../components/Island';
2929
import { ItemLinkBlockElement } from '../components/ItemLinkBlockElement';
3030
import { KeyTakeaways } from '../components/KeyTakeaways';
3131
import { KnowledgeQuizAtom } from '../components/KnowledgeQuizAtom.importable';
32-
import { LoopVideoInArticle } from '../components/LoopVideoInArticle';
32+
import { SelfHostedVideoInArticle } from '../components/SelfHostedVideoInArticle';
3333
import { MainMediaEmbedBlockComponent } from '../components/MainMediaEmbedBlockComponent';
3434
import { MapEmbedBlockComponent } from '../components/MapEmbedBlockComponent.importable';
3535
import { MiniProfiles } from '../components/MiniProfiles';
@@ -493,22 +493,16 @@ export const renderElement = ({
493493
</Island>
494494
);
495495
case 'model.dotcomrendering.pageElements.MediaAtomBlockElement':
496-
/*
497-
- MediaAtomBlockElement is used for self-hosted videos
498-
- Historically, these videos have been self-hosted for legal or sensitive reasons
499-
- These videos play in the `VideoAtom` component
500-
- Looping videos, introduced in July 2025, are also self-hosted
501-
- Thus they are delivered as a MediaAtomBlockElement
502-
- However they need to display in a different video player
503-
- We need to differentiate between the two forms of video
504-
- We can do this by interrogating the atom's metadata, which includes the new attribute `videoPlayerFormat`
505-
*/
506-
if (element.videoPlayerFormat === 'Loop') {
496+
if (
497+
element.videoPlayerFormat &&
498+
['Loop', 'Cinemagraph'].includes(element.videoPlayerFormat)
499+
) {
507500
return (
508-
<LoopVideoInArticle
501+
<SelfHostedVideoInArticle
509502
element={element}
510503
format={format}
511504
isMainMedia={isMainMedia}
505+
videoStyle={element.videoPlayerFormat}
512506
/>
513507
);
514508
} else {

0 commit comments

Comments
 (0)