Skip to content

Broken images in CODE articles #13900

Closed
@CDicksonG

Description

@CDicksonG

CODE images have been broken in CODE for YEARS I finally took the time yesterday to investigate with @rtyley (thank you very much Roberto) and we think we have identified the offending code.

export const generateImageURL = ({
mainImage,
imageWidth,
resolution,
aspectRatio = 'none',
cropOffset,
}: {
mainImage: string;
imageWidth: number;
resolution: 'low' | 'high';
aspectRatio?: string;
cropOffset?: { x: number; y: number };
}): string => {
const url = new URL(mainImage);
const offset = cropOffset
? `,offset-x${cropOffset.x},offset-y${cropOffset.y}`
: ``;
const crop = `${aspectRatio}${offset}`;
// In CODE, we do not generate optimised replacement images
if (url.hostname === 's3-eu-west-1.amazonaws.com') return url.href;
const params = new URLSearchParams({
width: imageWidth.toString(),
dpr: String(resolution === 'high' ? 2 : 1),
s: 'none',
crop,
});
return `https://i.guim.co.uk/img/${getServiceFromUrl(url)}${

CODE images should be pointed to the "guimcode" url e.g.

https://i.guimcode.co.uk/img/media/...

but are actually pointed at the PROD url e.g.

https://i.guim.co.uk/img/media/...

Which causes the image to fail to display

Example:

This article in CODE
https://composer.code.dev-gutools.co.uk/content/68148efb8f088f70b517344a
https://preview.code.dev-gutools.co.uk/uk-news/2025/may/02/new-article-test

main media is trying to hit
https://i.guim.co.uk/img/media/ccdce462daa5222f5c406518e73cc54a14a4fbe3/0_594_2396_1437/master/2396.jpg?width=1900&dpr=2&s=none&crop=none
for the image

but should be
https://i.guimcode.co.uk/img/media/ccdce462daa5222f5c406518e73cc54a14a4fbe3/0_594_2396_1437/master/2396.jpg?width=1900&dpr=2&s=none&crop=none

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions