##// END OF EJS Templates
Merged r13218 (#16989)....
Jean-Philippe Lang -
r12949:58a06386ca4e
parent child
Show More
@@ -236,8 +236,11 module Redmine
236 size = nil unless size > 0
236 size = nil unless size > 0
237 if obj && obj.respond_to?(:attachments) && attachment = Attachment.latest_attach(obj.attachments, filename)
237 if obj && obj.respond_to?(:attachments) && attachment = Attachment.latest_attach(obj.attachments, filename)
238 title = options[:title] || attachment.title
238 title = options[:title] || attachment.title
239 img = image_tag(url_for(:controller => 'attachments', :action => 'thumbnail', :id => attachment, :size => size), :alt => attachment.filename)
239 thumbnail_url = url_for(:controller => 'attachments', :action => 'thumbnail', :id => attachment, :size => size, :only_path => false)
240 link_to(img, url_for(:controller => 'attachments', :action => 'show', :id => attachment), :class => 'thumbnail', :title => title)
240 image_url = url_for(:controller => 'attachments', :action => 'show', :id => attachment, :only_path => false)
241
242 img = image_tag(thumbnail_url, :alt => attachment.filename)
243 link_to(img, image_url, :class => 'thumbnail', :title => title)
241 else
244 else
242 raise "Attachment #{filename} not found"
245 raise "Attachment #{filename} not found"
243 end
246 end
@@ -302,8 +302,8 RAW
302 end
302 end
303
303
304 def test_macro_thumbnail
304 def test_macro_thumbnail
305 link = link_to('<img alt="testfile.PNG" src="/attachments/thumbnail/17" />'.html_safe,
305 link = link_to('<img alt="testfile.PNG" src="http://test.host/attachments/thumbnail/17" />'.html_safe,
306 "/attachments/17",
306 "http://test.host/attachments/17",
307 :class => "thumbnail",
307 :class => "thumbnail",
308 :title => "testfile.PNG")
308 :title => "testfile.PNG")
309 assert_equal "<p>#{link}</p>",
309 assert_equal "<p>#{link}</p>",
@@ -311,8 +311,8 RAW
311 end
311 end
312
312
313 def test_macro_thumbnail_with_size
313 def test_macro_thumbnail_with_size
314 link = link_to('<img alt="testfile.PNG" src="/attachments/thumbnail/17/200" />'.html_safe,
314 link = link_to('<img alt="testfile.PNG" src="http://test.host/attachments/thumbnail/17/200" />'.html_safe,
315 "/attachments/17",
315 "http://test.host/attachments/17",
316 :class => "thumbnail",
316 :class => "thumbnail",
317 :title => "testfile.PNG")
317 :title => "testfile.PNG")
318 assert_equal "<p>#{link}</p>",
318 assert_equal "<p>#{link}</p>",
@@ -320,8 +320,8 RAW
320 end
320 end
321
321
322 def test_macro_thumbnail_with_title
322 def test_macro_thumbnail_with_title
323 link = link_to('<img alt="testfile.PNG" src="/attachments/thumbnail/17" />'.html_safe,
323 link = link_to('<img alt="testfile.PNG" src="http://test.host/attachments/thumbnail/17" />'.html_safe,
324 "/attachments/17",
324 "http://test.host/attachments/17",
325 :class => "thumbnail",
325 :class => "thumbnail",
326 :title => "Cool image")
326 :title => "Cool image")
327 assert_equal "<p>#{link}</p>",
327 assert_equal "<p>#{link}</p>",
General Comments 0
You need to be logged in to leave comments. Login now