Skip to content

Add image number above caption in Hosted Gallery#16207

Open
deedeeh wants to merge 3 commits into
mainfrom
dina/add-picture-index-hosted-gallery
Open

Add image number above caption in Hosted Gallery#16207
deedeeh wants to merge 3 commits into
mainfrom
dina/add-picture-index-hosted-gallery

Conversation

@deedeeh

@deedeeh deedeeh commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

What does this change?

This PR adds the image number above the caption in Hosted Content Gallery.

Tested locally with multiple Hosted Galleries and it works as expected.

Why?

Migrating Hosted Content to DCAR and Hosted Gallery is the last page to migrate. The new designs require this change.

Screenshots

Before After
before after
before2 after2
before3 after3

@deedeeh deedeeh added maintenance Departmental tracking: maintenance work, not a fix or a feature Commercial 💰 labels Jun 18, 2026
@deedeeh deedeeh changed the title Add image index in Hosted Gallery Add image number above caption in Hosted Gallery Jun 18, 2026
Comment thread dotcom-rendering/src/components/GalleryCaption.tsx
@deedeeh deedeeh marked this pull request as ready for review June 18, 2026 12:18
@github-actions

Copy link
Copy Markdown

Hello 👋! When you're ready to run Chromatic, please apply the run_chromatic label to this PR.

You will need to reapply the label each time you want to run Chromatic.

Click here to see the Chromatic project.

@github-actions

github-actions Bot commented Jun 18, 2026

Copy link
Copy Markdown

@deedeeh deedeeh force-pushed the dina/add-picture-index-hosted-gallery branch from d3723a3 to 099df65 Compare June 18, 2026 13:32

@dskamiotis dskamiotis left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me Dina, nice move with the isHostedContent to be the gate the share button inclusion

Comment thread dotcom-rendering/src/components/GalleryCaption.tsx
Comment thread dotcom-rendering/src/components/GalleryCaption.tsx Outdated
@deedeeh deedeeh force-pushed the dina/add-picture-index-hosted-gallery branch from 099df65 to 40a7f7c Compare June 22, 2026 07:20
@github-actions

github-actions Bot commented Jun 22, 2026

Copy link
Copy Markdown

@deedeeh deedeeh force-pushed the dina/add-picture-index-hosted-gallery branch from 40a7f7c to aa86282 Compare June 22, 2026 09:04
@deedeeh deedeeh requested review from a team and dskamiotis June 22, 2026 09:12

@cemms1 cemms1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great! Though I think we can re-use position here instead of creating imageIndex for brevity. I left a comment explaining what I'm thinking. Let me know if you want to chat about it

Comment on lines +25 to +26
imagesLength?: number;
imageIndex?: number;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we add a description to these props to indicate that they are only used to display the image number in hosted gallery pages?

webTitle={webTitle}
position={image.position}
imagesLength={images?.length}
imageIndex={imageIndex}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we already have position so it might be worth trying to reuse that. The problem with position is that this takes into account mainMedia, which we omit in HostedGallery pages.

If we strip mainMedia out of the hosted gallery data (which we should do anyway as we throw it away at the rendering stage) we should be able to just use position here.

To do that, we'd add a condition to the enhance step to omit main media for hosted gallery pages

const enhance =
(
isPhotoEssay: boolean,
imagesForLightbox: ImageForLightbox[],
isPhotoEssayMainMedia = false,
) =>
(elements: FEElement[]): FEElement[] => {
if (isPhotoEssay) {
if (isPhotoEssayMainMedia) {
return new Enhancer(elements)
.addMultiImageElements()
.addTitles()
.addCaptionsToMultis()
.addCaptionsToImages()
.addImagePositions(imagesForLightbox).elements;
}
return new Enhancer(elements)
.stripCaptions()
.removeCredit()
.addMultiImageElements()
.addTitles()
.addCaptionsToMultis()
.addCaptionsToImages()
.addImagePositions(imagesForLightbox).elements;
}
return (
new Enhancer(elements)
// Replace pairs of halfWidth images with MultiImageBlockElements
.addMultiImageElements()
// If any MultiImageBlockElement is followed by a ul/l caption, delete the special caption
// element and use the value for the multi image `caption` prop
.addCaptionsToMultis()
.addImagePositions(imagesForLightbox).elements
);
};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@deedeeh I'm happy to do this in a separate PR, then you can use position in this PR to simplify things

@dskamiotis dskamiotis left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice refactor for the image position index - looks good to me 👍

<figcaption css={styles}>
{isHostedGallery &&
typeof position === 'number' &&
imageIndex !== undefined &&

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice approach, a bit easier to follow but still as affective 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Commercial 💰 maintenance Departmental tracking: maintenance work, not a fix or a feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants