From 4156983494500a24ed4fdf9352b86f2f7bb4c205 Mon Sep 17 00:00:00 2001 From: nwb Date: Tue, 20 May 2014 15:05:54 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BC=BA=E9=99=B7=E6=B7=BB=E5=8A=A0=E7=BC=A9?= =?UTF-8?q?=E7=95=A5=E5=9B=BE=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/application_helper.rb | 20 ++++++++++++++++++-- app/models/attachment.rb | 1 - app/views/attachments/_links.html.erb | 2 +- app/views/users/_my_course.html.erb | 2 +- 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 6b8525a00..0c4514769 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -182,11 +182,27 @@ module ApplicationHelper end def thumbnail_tag(attachment) - link_to image_tag(thumbnail_path(attachment)), - named_attachment_path(attachment, attachment.filename), + imagepath = named_attachment_path(attachment, attachment.filename) + link_to image_tag(imagepath), + imagepath , :title => attachment.filename end + # 图片缩略图链接 + def thumbnail_small_tag(attachment) + imagesize = attachment.thumbnail(:size => "200*200") + imagepath = named_attachment_path(attachment, attachment.filename) + if imagesize + link_to image_tag(imagesize), + imagepath, + :title => attachment.filename + else + link_to image_tag(imagepath , height: '200', width: '250'), + imagepath, + :title => attachment.filename + end + end + def toggle_link(name, id, options={}) onclick = "$('##{id}').toggle(); " onclick << (options[:focus] ? "$('##{options[:focus]}').focus(); " : "this.blur(); ") diff --git a/app/models/attachment.rb b/app/models/attachment.rb index 661762e5c..aff63439e 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -228,7 +228,6 @@ class Attachment < ActiveRecord::Base end size = 100 unless size > 0 target = File.join(self.class.thumbnails_storage_path, "#{id}_#{digest}_#{size}.thumb") - begin Redmine::Thumbnail.generate(self.diskfile, target, size) rescue => e diff --git a/app/views/attachments/_links.html.erb b/app/views/attachments/_links.html.erb index c135ee214..f73df8fb4 100644 --- a/app/views/attachments/_links.html.erb +++ b/app/views/attachments/_links.html.erb @@ -33,7 +33,7 @@ <% if images.any? %>
<% images.each do |attachment| %> -
<%= thumbnail_tag(attachment) %>
+
<%= thumbnail_small_tag(attachment) %>
<% end %>
<% end %> diff --git a/app/views/users/_my_course.html.erb b/app/views/users/_my_course.html.erb index 2fb2b5bde..8feb0ecca 100644 --- a/app/views/users/_my_course.html.erb +++ b/app/views/users/_my_course.html.erb @@ -12,7 +12,7 @@ <% end %> <% else %>

- <%=l(:label_course_doing)%>(<%=@memberships_doing.count%>) + <%=l(:label_course_doing)%>(<%=@memberships_doing.count%>) <%= link_to"#{l(:label_course_new)}",{:controller=>'projects',:action=>'new', :course => 1, :project_type => 1}, :class => 'icon icon-add' if @user == User.current %>