Merged r13218 (#16989).

git-svn-id: http://svn.redmine.org/redmine/branches/2.5-stable@13224 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang
2014-07-06 10:31:15 +00:00
parent eac2cc272b
commit 58a06386ca
2 changed files with 11 additions and 8 deletions

View File

@@ -236,8 +236,11 @@ module Redmine
size = nil unless size > 0
if obj && obj.respond_to?(:attachments) && attachment = Attachment.latest_attach(obj.attachments, filename)
title = options[:title] || attachment.title
img = image_tag(url_for(:controller => 'attachments', :action => 'thumbnail', :id => attachment, :size => size), :alt => attachment.filename)
link_to(img, url_for(:controller => 'attachments', :action => 'show', :id => attachment), :class => 'thumbnail', :title => title)
thumbnail_url = url_for(:controller => 'attachments', :action => 'thumbnail', :id => attachment, :size => size, :only_path => false)
image_url = url_for(:controller => 'attachments', :action => 'show', :id => attachment, :only_path => false)
img = image_tag(thumbnail_url, :alt => attachment.filename)
link_to(img, image_url, :class => 'thumbnail', :title => title)
else
raise "Attachment #{filename} not found"
end

View File

@@ -302,8 +302,8 @@ RAW
end
def test_macro_thumbnail
link = link_to('<img alt="testfile.PNG" src="/attachments/thumbnail/17" />'.html_safe,
"/attachments/17",
link = link_to('<img alt="testfile.PNG" src="http://test.host/attachments/thumbnail/17" />'.html_safe,
"http://test.host/attachments/17",
:class => "thumbnail",
:title => "testfile.PNG")
assert_equal "<p>#{link}</p>",
@@ -311,8 +311,8 @@ RAW
end
def test_macro_thumbnail_with_size
link = link_to('<img alt="testfile.PNG" src="/attachments/thumbnail/17/200" />'.html_safe,
"/attachments/17",
link = link_to('<img alt="testfile.PNG" src="http://test.host/attachments/thumbnail/17/200" />'.html_safe,
"http://test.host/attachments/17",
:class => "thumbnail",
:title => "testfile.PNG")
assert_equal "<p>#{link}</p>",
@@ -320,8 +320,8 @@ RAW
end
def test_macro_thumbnail_with_title
link = link_to('<img alt="testfile.PNG" src="/attachments/thumbnail/17" />'.html_safe,
"/attachments/17",
link = link_to('<img alt="testfile.PNG" src="http://test.host/attachments/thumbnail/17" />'.html_safe,
"http://test.host/attachments/17",
:class => "thumbnail",
:title => "Cool image")
assert_equal "<p>#{link}</p>",