Skip to content

Remove PfC code and consolidate onto ImageCardComponent [WHIT-3983] - #11772

Open
ChrisBAshton wants to merge 11 commits into
mainfrom
images-improvements
Open

Remove PfC code and consolidate onto ImageCardComponent [WHIT-3983]#11772
ChrisBAshton wants to merge 11 commits into
mainfrom
images-improvements

Conversation

@ChrisBAshton

@ChrisBAshton ChrisBAshton commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

What

  • Removes some image-related features that were only being used for the (now deleted) Plan for Change pages
  • Extends the ImageCardComponent to support markdown embed codes, and dynamic thumbnail injection
  • Swaps "embeddable images" use of ImageComponent, for ImageCardComponent, in line with designs earlier in 2026
  • Deletes the now unused ImageComponent

Why

We're investigating reports of images intermittently rendering. Whilst investigating that, we uncovered a fair amount of avoidable image rendering complexity, which is paid down in this PR. It doesn't solve the original issue, but it gives us a cleaner base from which to investigate futher.

Jira: https://gov-uk.atlassian.net/browse/WHIT-3983

Screenshots

Before After
staging - upload int - upload
staging - images integration - images

⚠️ This repo is Continuously Deployed: make sure you follow the guidance ⚠️

This application is owned by the Whitehall Experience team. Please let us know in #govuk-whitehall-experience-tech when you raise any PRs.

Follow these steps if you are doing a Rails upgrade.

This was added in 75c3f23, when
EditionImagesController made multiple calls to `image_data.file.download!`.
Those calls no longer exist.
This reverts commit a973a52.

This functionality was set up to distinguish between image kinds
on the old Plan For Change style Landing Pages, which were never
migrated to the new ImageCardComponent way of doing things. The
PfC pages have since been deleted. Any other document types that
have multiple image kinds (e.g. Topical Events, with header, logo
and embeddable Govspeak images) use the new ImageCardComponent
pattern. So we can remove this unnecessary grouping in the
"Uploaded images" section (which appears below where the
ImageCardComponent kinds are rendered).
This reverts most of commit de4696f,
which added some logic to include a horizontal rule that was only
in force on the PfC images tab.
@ChrisBAshton
ChrisBAshton force-pushed the images-improvements branch 4 times, most recently from cebf924 to 4d63409 Compare September 8, 2026 10:49
This was only used on the PfC pages, which have now been removed.
It used to be that there was a shared image uploader for every kind
of image, and the user had to specify what kind of image they were
uploading in order to then get the correct validation etc on that
image.

Now, we have a dedicated image uploader for every image kind, so
this branching logic is redundant.
We're going to switch to using the ImageCardComponent when
rendering the "Uploaded images" section. One thing the current
ImageComponent does that ImageCardComponent does not is render
the markdown embed code, and also account for legacy editions
where multiple images of the same filename may have been uploaded.

In this commit we've copied over the tests and logic from the
ImageComponent.
This previously returned 'image' for embeddable images, the logic
for which was introduced in PR #11358. Looking at the PR, the
embeddable image title never actually seemed to get used - or at
least it no longer seems to be used in the current iteration of
the code.

When we swap out the "Uploaded images" section to use this title,
we'll want to call it "Embeddable image" on the top of the card,
otherwise we repeat "Image" in the card title followed by "Image"
as the first row of data, which looks a bit odd.
The previous code required the 'status check' element to be a
direct descendent of the 'image-processing-checker' data module
container, but there's no reason why we can't have the 'status
check' element nested several layers deep in the DOM. This
straightforward swap-out of code allows for that.
This behaviour already exists on the cropping screen and on the
specialised images area (e.g. Header logo), but general embeddable
images still got stuck displaying "Processing" and required users
to refresh the page.
@ChrisBAshton ChrisBAshton changed the title Improvements to Images Remove PfC code and consolidate onto ImageCardComponent [WHIT-3983] Sep 8, 2026
We're pointlessly maintaining two different components for
rendering a summary of an image within Whitehall. It means we're
also duplicating logic around checking for uploaded state, showing
a 'processing label', and so on. The long term aim has always
been to converge onto a single 'cards' design, and the technical
pay-off in being able to delete a redundant component and its
suite of tests means it is now worth making that change. The
card concept has been sufficiently bedded in, as it's been the
way of expressing a document's "lead" image for many months now.
This was only used on the Images tab for "Uploaded images"
(embeddable images). This has now been swapped out to use the
image card component.
@ChrisBAshton
ChrisBAshton marked this pull request as ready for review September 8, 2026 12:43
The ImageCardComponent is also used for Topical Event Header Image
and Topical Event Logo, neither of which use the
LeadImageCardComponent branch of logic in
https://github.com/alphagov/whitehall/blob/e5f9e1bdbd5f852c9ff037808f97e42db780342e/app/views/admin/edition_images/index.html.erb#L24

This was causing the `<li>` to appear without any parent `<ul>`
and therefore the browser's default 'bullets' to be rendered
(normally suppressed with `govuk-list` class on the `<ul>`).

There's no need for this to be an actual list in the markup - let's
go with a div wrapping a div.

@GDSNewt GDSNewt 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.

Didn't spot anything else other that the potential issue arising from hardcoding the html id 🤓

<% unless (idx + 1) == current_images.size %>
<li aria-hidden="true"><hr class="app-view-edition-resource__section-break govuk-section-break govuk-section-break--visible"></li>
<% end %>
<ul id="uploaded_embeddable_image_list" class="govuk-list">

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.

If you had a document type config with

"usages": {
  "example 1": {
    "multiple": true,
  },
  "example 2": {
    "multiple": true,
  }
}

would it result in two divs ala


<div id="uploaded_embeddable_image_list">
</div>

...

<div id="uploaded_embeddable_image_list">
</div>

I don't think we have any config types writtenlike that currently, but could be an issue in future?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants