Skip to content

Commit 5ee2052

Browse files
5:4 images ab test (#13365)
* 5:4 images ab test
1 parent 046b1e5 commit 5ee2052

File tree

8 files changed

+63
-0
lines changed

8 files changed

+63
-0
lines changed

dotcom-rendering/src/components/ImageComponent.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
type ArticleFormat,
1616
} from '../lib/articleFormat';
1717
import { getLargest, getMaster } from '../lib/image';
18+
import { useAB } from '../lib/useAB';
1819
import { palette as themePalette } from '../palette';
1920
import type {
2021
ImageBlockElement,
@@ -266,6 +267,12 @@ export const ImageComponent = ({
266267
isAvatar,
267268
isTimeline = false,
268269
}: Props) => {
270+
const abTestAPI = useAB()?.api;
271+
const isInFiveFourImagesAbTestVariant = abTestAPI?.isUserInVariant(
272+
'FiveFourImages',
273+
'variant',
274+
);
275+
269276
const { renderingTarget } = useConfig();
270277
// Its possible the tools wont send us any images urls
271278
// if so, don't try to render
@@ -306,6 +313,13 @@ export const ImageComponent = ({
306313

307314
const loading = isMainMedia ? 'eager' : 'lazy';
308315

316+
const aspectOverride =
317+
isInFiveFourImagesAbTestVariant &&
318+
isMainMedia &&
319+
image.fields.aspectRatio === '5:3'
320+
? { aspectRatio: '5:4' }
321+
: {};
322+
309323
if (
310324
isMainMedia &&
311325
format.display === ArticleDisplay.Immersive &&
@@ -363,6 +377,7 @@ export const ImageComponent = ({
363377
height={imageHeight}
364378
loading={loading}
365379
isMainMedia={isMainMedia}
380+
{...aspectOverride}
366381
/>
367382
)}
368383

@@ -423,6 +438,7 @@ export const ImageComponent = ({
423438
height={imageHeight}
424439
loading={loading}
425440
isMainMedia={isMainMedia}
441+
{...aspectOverride}
426442
/>
427443
)}
428444

@@ -489,6 +505,7 @@ export const ImageComponent = ({
489505
height={imageHeight}
490506
loading={loading}
491507
isMainMedia={isMainMedia}
508+
{...aspectOverride}
492509
/>
493510
)}
494511
{isTimeline && isMainMedia && role === 'showcase' && (

dotcom-rendering/src/experiments/ab-tests.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { abTestTest } from './tests/ab-test-test';
33
import { adBlockAsk } from './tests/ad-block-ask';
44
import { auxiaSignInGate } from './tests/auxia-sign-in-gate';
55
import { consentlessAds } from './tests/consentless-ads';
6+
import { fiveFourImages } from './tests/five-four-images';
67
import { integrateIma } from './tests/integrate-ima';
78
import { mpuWhenNoEpic } from './tests/mpu-when-no-epic';
89
import { optimiseSpacefinderInline } from './tests/optimise-spacefinder-inline';
@@ -23,4 +24,5 @@ export const tests: ABTest[] = [
2324
optimiseSpacefinderInline,
2425
userBenefitsApi,
2526
auxiaSignInGate,
27+
fiveFourImages,
2628
];
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import type { ABTest } from '@guardian/ab-core';
2+
3+
export const fiveFourImages: ABTest = {
4+
id: 'FiveFourImages',
5+
start: '2025-02-20',
6+
expiry: '2026-01-30',
7+
author: '[email protected]',
8+
description: 'Compare 5:4 vs 5:3 aspect ratio in article main media images',
9+
audience: 0,
10+
audienceOffset: 0,
11+
successMeasure:
12+
'There is not any negative change to the metrics on the variant of the article pages',
13+
audienceCriteria: '',
14+
dataLinkNames: 'FiveFourImages',
15+
idealOutcome: '',
16+
canRun: () => true,
17+
variants: [
18+
{
19+
id: 'control',
20+
test: (): void => {
21+
/* no-op */
22+
},
23+
},
24+
{
25+
id: 'variant',
26+
test: (): void => {
27+
/* no-op */
28+
},
29+
},
30+
],
31+
};

dotcom-rendering/src/frontend/schemas/feTagPage.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1415,6 +1415,9 @@
14151415
"width": {
14161416
"type": "string"
14171417
},
1418+
"aspectRatio": {
1419+
"type": "string"
1420+
},
14181421
"isMaster": {
14191422
"type": "string"
14201423
},

dotcom-rendering/src/model/article-schema.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1615,6 +1615,9 @@
16151615
"width": {
16161616
"type": "string"
16171617
},
1618+
"aspectRatio": {
1619+
"type": "string"
1620+
},
16181621
"isMaster": {
16191622
"type": "string"
16201623
},

dotcom-rendering/src/model/block-schema.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,6 +1102,9 @@
11021102
"width": {
11031103
"type": "string"
11041104
},
1105+
"aspectRatio": {
1106+
"type": "string"
1107+
},
11051108
"isMaster": {
11061109
"type": "string"
11071110
},

dotcom-rendering/src/model/front-schema.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3194,6 +3194,9 @@
31943194
"width": {
31953195
"type": "string"
31963196
},
3197+
"aspectRatio": {
3198+
"type": "string"
3199+
},
31973200
"isMaster": {
31983201
"type": "string"
31993202
},

dotcom-rendering/src/types/content.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -866,6 +866,7 @@ export interface Image {
866866
fields: {
867867
height: string;
868868
width: string;
869+
aspectRatio?: string;
869870
isMaster?: string;
870871
source?: string;
871872
caption?: string;

0 commit comments

Comments
 (0)