|
| 1 | +<% |
| 2 | + image_kind ||= Whitehall.image_kinds.fetch("default") |
| 3 | + text = image_kind.permitted_uses.include?("govspeak_embed") ? "Upload an image" : "Upload #{image_kind.display_name} image" |
| 4 | +%> |
| 5 | + |
1 | 6 | <%= form_tag( |
2 | 7 | admin_edition_images_path(@edition), |
| 8 | + id: "#{image_kind.name}_image_upload_form", |
3 | 9 | multipart: true, |
4 | 10 | ) do %> |
5 | 11 | <%= render "govuk_publishing_components/components/file_upload", { |
6 | 12 | label: { |
7 | | - text: "Upload an image", |
| 13 | + text:, |
8 | 14 | }, |
9 | 15 | heading_level: 2, |
10 | 16 | heading_size: "l", |
11 | 17 | javascript: true, |
12 | | - multiple: true, |
| 18 | + multiple: @edition.allows_multiple_of_image_kind?(image_kind.permitted_uses.first), |
13 | 19 | name: "images[][image_data][file]", |
14 | 20 | id: "edition_images_image_data_file", |
15 | 21 | hint: raw('Images can be JPEG, PNG, SVG or GIF files. If you are uploading more than one image, <a class="govuk-link" href="https://www.gov.uk/guidance/how-to-publish-on-gov-uk/images-and-videos">read the image guidance</a> on using unique file names.'), |
16 | 22 | error_items: @new_image.present? ? errors_for(@new_image.errors, :"image_data.file") : nil, |
17 | 23 | accept: "image/png, image/jpeg, image/gif, image/svg+xml", |
18 | 24 | } %> |
19 | 25 |
|
20 | | - <% if @edition.permitted_image_kinds.size == 1 %> |
21 | | - <%= hidden_field_tag("image[image_data][image_kind]", @edition.permitted_image_kinds.first.name) %> |
| 26 | + <% if image_kind.present? %> |
| 27 | + <%= hidden_field_tag("images[][image_data][image_kind]", image_kind.name) %> |
22 | 28 | <% else %> |
23 | 29 | <%= render "govuk_publishing_components/components/radio", { |
24 | 30 | heading: "What kind of image is this?", |
25 | | - name: "image[image_data][image_kind]", |
| 31 | + name: "images[][image_data][image_kind]", |
26 | 32 | items: @edition.permitted_image_kinds.map do |image_kind| |
27 | 33 | { |
28 | 34 | value: image_kind.name, |
|
0 commit comments