Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ describe('Hierarchical Grid Curation', () => {
blocks: aresMediaBlocks,
uniqueId: `in-situ-${inSituPromo.id}`,
loadPlayerOnInitialRender: true,
holdingImageURL: inSituPromo.imageUrl,
}),
undefined,
);
Expand Down
1 change: 1 addition & 0 deletions src/app/components/Curation/HierarchicalGrid/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ const HiearchicalGrid = ({
blocks={inSituMediaBlocks}
uniqueId={`in-situ-${promo.id || i}`}
loadPlayerOnInitialRender
holdingImageURL={promo.imageUrl}
Comment thread
Nabeel1276 marked this conversation as resolved.
/>
</div>
<div className="promo-text">{promoText}</div>
Expand Down
23 changes: 14 additions & 9 deletions src/app/components/MediaLoader/configs/aresMedia.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export default ({
showAdsBasedOnLocation = false,
embedded,
lang,
holdingImageURL: holdingImageURLOverride,
}: ConfigBuilderProps): ConfigBuilderReturnProps => {
const { model: aresMedia }: AresMediaBlock =
filterForBlockType(blocks, 'aresMedia') ?? {};
Expand Down Expand Up @@ -87,13 +88,15 @@ export default ({
// Referred to as 'clip PID', 'episode PID' or 'parent PID'
const parentPID = aresMediaMetadata?.id;

const holdingImageURL = rawImage
? buildIChefURL({
originCode,
locator,
resolution: DEFAULT_WIDTH,
})
: aresMediaMetadata?.imageUrl;
const holdingImageURL =
holdingImageURLOverride?.replace('{width}', String(DEFAULT_WIDTH)) ||
(rawImage
? buildIChefURL({
originCode,
locator,
resolution: DEFAULT_WIDTH,
})
: aresMediaMetadata?.imageUrl);

const isLive = aresMediaMetadata?.live ?? false;

Expand All @@ -116,8 +119,10 @@ export default ({
guidanceMessage,
holdingImageURL,
translations,
placeholderImageOriginCode: originCode,
placeholderImageLocator: locator,
placeholderImageOriginCode: holdingImageURLOverride
? undefined
: originCode,
placeholderImageLocator: holdingImageURLOverride ? undefined : locator,
});

const ampIframeUrl = getAmpIframeUrl({ id, parentPID, versionPID, lang });
Expand Down
19 changes: 19 additions & 0 deletions src/app/components/MediaLoader/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,25 @@ describe('MediaLoader', () => {
);
},
);

it('passes a supplied holding image to the player configuration', async () => {
const buildConfigSpy = jest.spyOn(buildConfig, 'default');
const holdingImageURL =
'https://ichef.bbci.co.uk/ace/ws/{width}/cpsprodpb/promo-image.jpg.webp';

await act(async () => {
render(
<MediaPlayer
blocks={aresMediaBlocks as MediaBlock[]}
holdingImageURL={holdingImageURL}
/>,
);
});

expect(buildConfigSpy).toHaveBeenCalledWith(
expect.objectContaining({ holdingImageURL }),
);
});
});

describe('AMP', () => {
Expand Down
3 changes: 3 additions & 0 deletions src/app/components/MediaLoader/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ type Props = {
uniqueId?: string;
eventMapping?: EventMapping;
loadPlayerOnInitialRender?: boolean;
holdingImageURL?: string;
};

const MediaLoader = ({
Expand All @@ -227,6 +228,7 @@ const MediaLoader = ({
uniqueId,
eventMapping,
loadPlayerOnInitialRender = false,
holdingImageURL,
}: Props) => {
const { lang, service, translations, defaultImage } = use(ServiceContext);
const { pageIdentifier } = use(EventTrackingContext);
Expand Down Expand Up @@ -268,6 +270,7 @@ const MediaLoader = ({
showAdsBasedOnLocation,
embedded,
defaultImage,
holdingImageURL,
});

if (!config) return null;
Expand Down
2 changes: 2 additions & 0 deletions src/app/components/MediaLoader/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ export type ConfigBuilderProps = {
embedded?: boolean;
lang: string;
defaultImage: string;
holdingImageURL?: string;
};

export type Orientations = 'landscape' | 'portrait';
Expand Down Expand Up @@ -382,4 +383,5 @@ export type BuildConfigProps = {
showAdsBasedOnLocation?: boolean;
embedded?: boolean;
defaultImage: string;
holdingImageURL?: string;
};
18 changes: 18 additions & 0 deletions src/app/components/MediaLoader/utils/buildSettings.client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,24 @@ describe('buildSettings', () => {
});

describe('AresMedia', () => {
it('uses a supplied holding image instead of the Ares media image', () => {
const holdingImageURL =
'https://ichef.bbci.co.uk/ace/ws/{width}/cpsprodpb/promo-image.jpg.webp';
const result = buildSettings({
...baseSettings,
blocks: aresMediaBlocks as MediaBlock[],
holdingImageURL,
});

expect(result?.playerConfig.playlistObject?.holdingImageURL).toBe(
holdingImageURL.replace('{width}', '512'),
);
expect(result?.placeholderConfig).toMatchObject({
placeholderSrc: holdingImageURL.replace('{width}', '512'),
placeholderSrcset: '',
});
});

it('Should process an AresMedia block into a valid playlist item for an "article" page.', () => {
const result = buildSettings({
...baseSettings,
Expand Down
2 changes: 2 additions & 0 deletions src/app/components/MediaLoader/utils/buildSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const buildSettings = ({
showAdsBasedOnLocation = false,
embedded,
defaultImage,
holdingImageURL,
}: BuildConfigProps) => {
const { model: mediaOverrides } =
filterForBlockType(blocks, 'mediaOverrides') || {};
Expand Down Expand Up @@ -86,6 +87,7 @@ const buildSettings = ({
embedded,
lang,
defaultImage,
holdingImageURL,
});

if (!config) return null;
Expand Down
Loading