-
Notifications
You must be signed in to change notification settings - Fork 197
[DO NOT MERGE] Spike configurable image kinds #10942
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
| "images_enabled": false, | ||
| "images": { | ||
| "enabled": true, | ||
| "permitted_image_kinds": ["header", "logo"] |
There was a problem hiding this comment.
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"]) } |
There was a problem hiding this comment.
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| %> |
There was a problem hiding this comment.
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) %> |
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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
3f54f5e to
f270441
Compare
f270441 to
806bb76
Compare
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