Skip to content

Conversation

@ryanb-gds
Copy link
Contributor

This is a basic spike of the approach we might take to implement configurable image kinds (initially to enable topical event header and logo images)

Most of the code in this draft PR is a copy of the edition images controller and view code with some minor tweaks to enable usage of image kinds in a way that allows users to upload an image specifically for that "kind" rather than having to upload an image and select the kind later.

JIRA

"images_enabled": false,
"images": {
"enabled": true,
"permitted_image_kinds": ["header", "logo"]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will need to turn this into an object so that we can say whether or not users should be able to upload multiple images of each kind.

def permitted_image_kinds
return super unless type_instance.settings["images"]["permitted_image_kinds"]

Whitehall.image_kinds.values.select { _1.permitted_uses.intersect?(type_instance.settings["images"]["permitted_image_kinds"]) }
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a bit ugly. Unfortunately the image kind config introduced during the landing page work does not put the usages at the root of the data structure. Instead it looks like aspect ratio -> usage -> versions (sizes). We can probably refactor this at a later date but it would mean changing landing pages. So perhaps when we convert landing pages to configurable documents is the time to do this.

items: secondary_navigation_tabs_items(@edition, request.path),
} %>

<% @edition.permitted_image_kinds.each do |image_kind| %>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the main change from the existing workflow, which just renders an upload input and some radio buttons for users to select the kind. Instead we iterate through the kinds and render an input for each. When we do the actual implementation we will probably render the card style component here.

<% @edition.permitted_image_kinds.each do |image_kind| %>
<%= render "image_upload", edition: @edition, image_kind: %>
<% end %>
<%= render Admin::EditionImages::UploadedImagesComponent.new(edition: @edition) %>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This component might not be used in the final implementation, as now we don't need to handle non-configurable document types in this template we can probably just render the images form

- name: hero_desktop_2x
width: 800
height: 800
topical_event_logo:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure on the best name for each of these. We may not want to make them topical event specific. Perhaps a question for information architect

@ryanb-gds ryanb-gds force-pushed the spike-configurable-image-kinds branch from 3f54f5e to f270441 Compare December 18, 2025 09:24
@ryanb-gds ryanb-gds force-pushed the spike-configurable-image-kinds branch from f270441 to 806bb76 Compare December 18, 2025 14:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants