From 8e953fb7becf204bfded23a38526fce7b43f2ae3 Mon Sep 17 00:00:00 2001 From: dani-sanchez-dorado Date: Fri, 11 May 2018 09:39:47 +0200 Subject: [PATCH] Fix issue #29 --- app/views/attachments/_links.html.erb | 50 +++++++++++++++------------ 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/app/views/attachments/_links.html.erb b/app/views/attachments/_links.html.erb index e39eb50..24ff3f9 100644 --- a/app/views/attachments/_links.html.erb +++ b/app/views/attachments/_links.html.erb @@ -59,30 +59,34 @@ <% end %> -<% if defined?(thumbnails) && thumbnails %> - <% images = attachments.select(&:thumbnailable?) %> - <% if images.any? %> -
- <% images.each do |attachment| %> -
- <%= - link_to image_tag(url_for(:controller => 'attachments', :action => 'thumbnail', :id => attachment)), - {:controller => 'attachments', :action => 'download', :id => attachment, :filename => attachment.filename}, - :class => ('lightbox' + (attachment.is_pdf? ? ' pdf' : '')) , :rel => 'thumbnails', :title => "#{attachment.filename}#{ ('-' + attachment.description) unless attachment.description.blank? }" - %> -
+ +<% if defined?(Setting.thumbnails_enabled) && Setting.thumbnails_enabled? %> + <% if defined?(thumbnails) && thumbnails %> + <% images = attachments.select(&:thumbnailable?) %> + <% if images.any? %> +
+ <% images.each do |attachment| %> +
+ <%= + link_to image_tag(url_for(:controller => 'attachments', :action => 'thumbnail', :id => attachment)), + {:controller => 'attachments', :action => 'download', :id => attachment, :filename => attachment.filename}, + :class => ('lightbox' + (attachment.is_pdf? ? ' pdf' : '')) , :rel => 'thumbnails', :title => "#{attachment.filename}#{ ('-' + attachment.description) unless attachment.description.blank? }" + %> +
+ <% end %> +
<% end %> -
+ <% else %> + <% images = attachments.select { |a| a.image? } %> + <% unless images.empty? %> +
+ <% images.each do |attachment| %> + <%= link_to image_tag(url_for({:controller => 'attachments', :action => 'download', :id => attachment, :filename => attachment.filename }), :width => Setting.thumbnails_size), + {:controller => 'attachments', :action => 'download', :id => attachment, :filename => attachment.filename }, :class => 'lightbox', :rel => 'thumbnails', :title => "#{attachment.filename}#{ ('-' + attachment.description) unless attachment.description.blank? }" %> + <% end -%> +
+ <% end -%> <% end %> -<% else %> - <% images = attachments.select { |a| a.image? } %> - <% unless images.empty? %> -
- <% images.each do |attachment| %> - <%= link_to image_tag(url_for({:controller => 'attachments', :action => 'download', :id => attachment, :filename => attachment.filename }), :width => '180'), - {:controller => 'attachments', :action => 'download', :id => attachment, :filename => attachment.filename }, :class => 'lightbox', :rel => 'thumbnails', :title => "#{attachment.filename}#{ ('-' + attachment.description) unless attachment.description.blank? }" %> - <% end -%> -
- <% end -%> <% end %> +