2020-02-04 11:24:13 +00:00
|
|
|
<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">
|
2020-02-04 16:37:03 +00:00
|
|
|
<% if(image_form.send(image_field_name).last.send(field_name).file.present? rescue false) %>
|
2020-02-04 11:24:13 +00:00
|
|
|
<div class="fileupload-new thumbnail pull-left">
|
2021-04-21 05:02:15 +00:00
|
|
|
<% file = image_form.send(image_field_name).last.send(field_name).to_s
|
|
|
|
extname = File.extname(file) rescue ".jpg"
|
|
|
|
extname = ".jpg" if extname.blank?
|
|
|
|
file_name = URI.decode(File.basename(file)) rescue File.basename(file)
|
|
|
|
%>
|
|
|
|
<% if extname.match(/(jpg|png|gif|bmp)/i) %>
|
|
|
|
<%= image_tag( image_form.send(image_field_name).last.send(field_name), :size=>"120x120") %>
|
|
|
|
<% elsif extname.match(/pdf/i) %>
|
|
|
|
<object data="<%=file%>" type="application/pdf" title="<%=file_name%>" height="120" width="120">
|
|
|
|
<a href="<%=file%>" title="<%=file_name%>"><%=file_name%></a>
|
|
|
|
<embed src="<%=file%>" title="<%=file_name%>" type="application/pdf" />
|
|
|
|
</object>
|
|
|
|
<% else %>
|
|
|
|
<a href="<%=file%>" title="<%=file_name%>"><%=file_name%></a>
|
|
|
|
<% end %>
|
2020-02-04 11:24:13 +00:00
|
|
|
</div>
|
|
|
|
<% end %>
|
|
|
|
<div class="fileupload-preview fileupload-exists thumbnail pull-left"></div>
|
2020-02-04 16:37:03 +00:00
|
|
|
<% if(image_form.send(image_field_name).last.send(field_name).file.present? rescue false)%>
|
2020-02-04 11:24:13 +00:00
|
|
|
<span class="btn btn-file">
|
|
|
|
<%= f.fields_for image_field_name do |index| %>
|
|
|
|
<%= index.fields_for "0" do |image| %>
|
2020-02-04 16:37:03 +00:00
|
|
|
<%= image.hidden_field(:_id,{:value=>image_form.send(image_field_name).last.id.to_s}) %>
|
2020-02-04 11:24:13 +00:00
|
|
|
<%= 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>
|
|
|
|
<%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>
|