Image Editor

<%= fields_for PageImage.new do |pi| %> <%= pi.fields_for(:image_attributes, Image.new) do |i| %> <%= i.hidden_field :id, class: 'image_id' %>
<%= i.text_field(:alternative, class: 'alternative', placeholder: 'Alternative text') %>
<%= i.text_field(:caption, class: 'caption', placeholder: 'Write your caption/byline') %>
<%= text_field_tag 'embed', '', class: 'embed' %> <%= pi.check_box :primary %> <%= i.hidden_field :crop_start_x, class: 'crop_start_x' %> <%= i.hidden_field :crop_start_y, class: 'crop_start_y' %> <%= i.hidden_field :crop_width, class: 'crop_width' %> <%= i.hidden_field :crop_height, class: 'crop_height' %> <% end %> <%= link_to "Delete image", '#', class: :delete %> <% end %>
<%= link_to "", '#', class: :previous %> <%= link_to "", '#', class: :next %>

No images have been uploaded.

<% if @page.image? && (page_image = @page.page_images.select{|pi| pi.primary?}.first) %> <%= dynamic_image_tag(page_image.image, size: '380x380', crop: true, upscale: true) %> <% end %>
<% @page.page_images.reject{|pi| pi.primary?}.each do |i| %> <%= dynamic_image_tag(i.image, size: '240x240', crop: true, upscale: true) %> <% end %>