<%= f.label a.to_sym, class: "form-control-label #{required?(f.object, a).present? ? 'required' : ''}" %> <% if f.object.send(a).is_a? Array %> <% multiple_files = true %> <% else %> <% multiple_files = false %> <% end %>
<% if multiple_files %> <% f.object.send(a).each_with_index do |file, i| %> <% extension = file.try(:extension).try(:downcase) || file.try(:format).try(:downcase) || file.try(:file).try(:extension) %> <% if extension.present? %> <% if %w{jpg png jpeg gif bmp}.include?(extension) %> <% if file.try(:url).present? %>
<% else %> <%= file.url %> <% end %> <% end %> <% else %> <%= t('slash_admin.view.no_image') %> <% end %> <% end %> <% else %> <% extension = f.object.send(a).file.try(:extension).try(:downcase) || f.object.send(a).file.try(:format).try(:downcase) || f.object.send(a).file.try(:file).try(:extension) %> <% if extension.present? %> <% if %w{jpg png jpeg gif bmp}.include?(extension) %> <% if f.object.send(a).try(:url).present? %>
<% end %> <% else %> <%= f.object.send(a) %> <% end %> <% else %> <%= t('slash_admin.view.no_image') %> <% end %> <% end %>
<%= f.hidden_field (a.to_s + '_cache').to_sym %> <%= f.file_field a, multiple: multiple_files %>
<% unless multiple_files %> <% if f.object.send(a).try(:url).present? && required?(f.object, a).blank? %>
<%= f.check_box ('remove_' + a.to_s).to_sym, class: 'form-check-input' %>
<% end %> <% end %>