ref: master
app/views/search/_image.html.erb
<% if image.is_a? UploadedFile and image.filename %> <% extension = image.extension %> <% if ['jpg', 'jpeg', 'gif', 'png', 'tiff', 'svg'].include? extension %> <%= link_to '', image.view_url, :class => "search-image-pic", :style => 'background-image: url(%s)'% image.public_filename(:thumb) %> <% if image.width && image.height %> <%= javascript_tag do %> image = jQuery('script').last().parent().find('.search-image-pic'); des_width = parseInt(image.css('width')); des_height = parseInt(image.css('height')); width = <%= image.width %>; height = <%= image.height %>; scale_factor = width > height ? des_width/width : des_height/height; image.css({'width' : scale_factor*width +'px', 'height' : scale_factor*height+'px'}); <% end %> <% end %> <% elsif ['pdf'].include? extension %> <%= link_to '', image.view_url, :class => 'icon-application-pdf' %> <% elsif ['doc', 'docx', 'odt', 'rtf', 'txt', 'html', 'htm'].include? extension %> <%= link_to '', image.view_url, :class => 'icon-application-vnd-oasis-opendocument-text' %> <% elsif ['xls', 'xlsx', 'ods', 'csv', 'tsv', 'tab'].include? extension %> <%= link_to '', image.view_url, :class => 'icon-application-vnd-oasis-opendocument-spreadsheet' %> <% end %> <% elsif image.is_a? Gallery %><% r = image.children.latest.images.limit(3) %> <% if r.length > 0 %> <% r.each_index do |i| img = r[i] %> <%= link_to '', img.view_url, :class => "search-image-pic pic-num#{i+1}", :style => 'background-image: url(%s)'% img.public_filename(:thumb) %> <% end %> <% else %><% else %> <% end %><%= _('No image') %><% end %>