缺陷添加缩略图显示

This commit is contained in:
nwb 2014-05-20 15:05:54 +08:00
parent 097489e594
commit 4156983494
4 changed files with 20 additions and 5 deletions

View File

@ -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(); ")

View File

@ -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

View File

@ -33,7 +33,7 @@
<% if images.any? %>
<div class="thumbnails">
<% images.each do |attachment| %>
<div><%= thumbnail_tag(attachment) %></div>
<div><%= thumbnail_small_tag(attachment) %></div>
<% end %>
</div>
<% end %>