olympiamanagement/app/views/admin/olympiamanagements/_image_form.html.erb

34 lines
1.8 KiB
Plaintext

<div class="control-group">
<div class="controls">
<!-- if this page editing please add class "fileupload-edit" -->
<div class="fileupload fileupload-new clearfix" data-provides="fileupload">
<% if(image_form.send(image_field_name).last.send(field_name).file.present? rescue false) %>
<div class="fileupload-new thumbnail pull-left">
<%= image_tag( image_form.send(image_field_name).last.send(field_name), :size=>"120x120") %>
</div>
<% end %>
<div class="fileupload-preview fileupload-exists thumbnail pull-left"></div>
<% if(image_form.send(image_field_name).last.send(field_name).file.present? rescue false)%>
<span class="btn btn-file">
<%= f.fields_for image_field_name do |index| %>
<%= index.fields_for "0" do |image| %>
<%= image.hidden_field(:_id,{:value=>image_form.send(image_field_name).last.id.to_s}) %>
<%= image.file_field field_name, {:id => (image_id rescue "input-upload"), :class => ('fileupload-new'+(@extra_class rescue "")), :accept=> 'image/png,image/gif,image/jpeg'} %><%= t('preferences.change') %>
<% end %>
<% end %>
</span>
<%= f.check_box(:remove_image,{:checked=>false},"true","false") %>
<%= t(:remove) %> <%= (I18n.locale.to_s == 'en') ? ' this image' : '該圖片' %>
<%else%>
<span class="btn btn-file">
<%= f.fields_for image_field_name do |index| %>
<%= index.fields_for "0" do |image| %>
<%= image.file_field field_name, {:id => (image_id rescue "input-upload"), :class => ('fileupload-new'+(@extra_class rescue "")), :accept=> 'image/png,image/gif,image/jpeg'} %><%= t('preferences.select_image') %>
<% end %>
<% end %>
</span>
<%end%>
<input type="button" value="<%= t(:cancel) %>" class="btn fileupload-exists" data-dismiss="fileupload">
</div>
</div>
</div>