<% content_for :page_title do %> Image Studio <% end %>

Upload photos straight off your phone or camera — background, framing and size are standardised, then posted to the store. Nothing is saved until you press Apply.

<%= form_with url: spree.admin_preview_image_studio_path, method: :post, local: true, multipart: true do |f| %>
1 · Photos
<%= file_field_tag 'photos[]', multiple: true, accept: 'image/*', id: 'photos', class: 'form-control' %>
Pick several at once. On a phone this opens the camera roll. Up to <%= @max_photos %> per batch — each takes a few seconds.
…or reprocess an image already on a product
Ignored when you upload files above.
2 · Look
<%= submit_tag 'Process photos', class: 'btn btn-primary w-100', data: { disable_with: 'Processing… this can take a minute' } %>
<% end %> <% if @results.present? %>
3 · Review

<%= @processed %> processed<%= ", #{@failed} failed" if @failed.to_i.positive? %> · <%= @size %>

<% @results.each_with_index do |r, i| %>
<%= r[:filename] %>
<% if r[:error].present? %>
Failed: <%= r[:error] %>
<% else %>
<%= image_tag r[:before_url], style: 'max-width:100%; height:auto;' %>

Before · <%= number_to_human_size(r[:before_bytes]) %>

<%= image_tag r[:after_url], style: 'max-width:100%; height:auto;' %>

After · <%= number_to_human_size(r[:after_bytes]) %>

<% end %>
<% end %>
<%= form_with url: spree.admin_apply_image_studio_path, method: :post, local: true do |f| %> <% @results.each do |r| %> <% next if r[:error].present? %> <%= hidden_field_tag 'signed_ids[]', r[:signed_id], id: nil %> <% end %>
4 · Post to store
<%= radio_button_tag :destination, 'existing', true, class: 'form-check-input', id: 'dest_existing' %>
<%= radio_button_tag :destination, 'new', false, class: 'form-check-input', id: 'dest_new' %>
<%= text_field_tag :new_name, params[:new_name], class: 'form-control', placeholder: 'Product name' %>
<%= text_field_tag :new_price, params[:new_price], class: 'form-control', placeholder: "Price (#{@currency})" %>
<%= check_box_tag :publish, '1', false, class: 'form-check-input', id: 'publish' %>
Left unpublished it is created as a draft, so you can add the description and details before customers see it.

<%= check_box_tag :make_primary, '1', true, class: 'form-check-input', id: 'make_primary' %>
Unchecked, they are added to the end of the gallery and the current main photo is left alone.
<%= submit_tag 'Apply to store', class: 'btn btn-primary' %> <%= link_to 'Discard', spree.admin_image_studio_path, class: 'btn btn-outline-secondary ms-2' %>

Discarding leaves the catalogue untouched — nothing was attached.

<% end %> <% end %>