##// END OF EJS Templates
Merged r13451 (#18119)....
Jean-Philippe Lang -
r13082:3a0a55c8ba37
parent child
Show More
@@ -589,7 +589,7 module ApplicationHelper
589 end
589 end
590 return '' if text.blank?
590 return '' if text.blank?
591 project = options[:project] || @project || (obj && obj.respond_to?(:project) ? obj.project : nil)
591 project = options[:project] || @project || (obj && obj.respond_to?(:project) ? obj.project : nil)
592 only_path = options.delete(:only_path) == false ? false : true
592 @only_path = only_path = options.delete(:only_path) == false ? false : true
593
593
594 text = text.dup
594 text = text.dup
595 macros = catch_macros(text)
595 macros = catch_macros(text)
@@ -236,8 +236,8 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 thumbnail_url = url_for(:controller => 'attachments', :action => 'thumbnail', :id => attachment, :size => size, :only_path => false)
239 thumbnail_url = url_for(:controller => 'attachments', :action => 'thumbnail', :id => attachment, :size => size, :only_path => @only_path)
240 image_url = url_for(:controller => 'attachments', :action => 'show', :id => attachment, :only_path => false)
240 image_url = url_for(:controller => 'attachments', :action => 'show', :id => attachment, :only_path => @only_path)
241
241
242 img = image_tag(thumbnail_url, :alt => attachment.filename)
242 img = image_tag(thumbnail_url, :alt => attachment.filename)
243 link_to(img, image_url, :class => 'thumbnail', :title => title)
243 link_to(img, image_url, :class => 'thumbnail', :title => title)
@@ -302,17 +302,26 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,
306 "/attachments/17",
307 :class => "thumbnail",
308 :title => "testfile.PNG")
309 assert_equal "<p>#{link}</p>",
310 textilizable("{{thumbnail(testfile.png)}}", :object => Issue.find(14))
311 end
312
313 def test_macro_thumbnail_with_full_path
305 link = link_to('<img alt="testfile.PNG" src="http://test.host/attachments/thumbnail/17" />'.html_safe,
314 link = link_to('<img alt="testfile.PNG" src="http://test.host/attachments/thumbnail/17" />'.html_safe,
306 "http://test.host/attachments/17",
315 "http://test.host/attachments/17",
307 :class => "thumbnail",
316 :class => "thumbnail",
308 :title => "testfile.PNG")
317 :title => "testfile.PNG")
309 assert_equal "<p>#{link}</p>",
318 assert_equal "<p>#{link}</p>",
310 textilizable("{{thumbnail(testfile.png)}}", :object => Issue.find(14))
319 textilizable("{{thumbnail(testfile.png)}}", :object => Issue.find(14), :only_path => false)
311 end
320 end
312
321
313 def test_macro_thumbnail_with_size
322 def test_macro_thumbnail_with_size
314 link = link_to('<img alt="testfile.PNG" src="http://test.host/attachments/thumbnail/17/200" />'.html_safe,
323 link = link_to('<img alt="testfile.PNG" src="/attachments/thumbnail/17/200" />'.html_safe,
315 "http://test.host/attachments/17",
324 "/attachments/17",
316 :class => "thumbnail",
325 :class => "thumbnail",
317 :title => "testfile.PNG")
326 :title => "testfile.PNG")
318 assert_equal "<p>#{link}</p>",
327 assert_equal "<p>#{link}</p>",
@@ -320,8 +329,8 RAW
320 end
329 end
321
330
322 def test_macro_thumbnail_with_title
331 def test_macro_thumbnail_with_title
323 link = link_to('<img alt="testfile.PNG" src="http://test.host/attachments/thumbnail/17" />'.html_safe,
332 link = link_to('<img alt="testfile.PNG" src="/attachments/thumbnail/17" />'.html_safe,
324 "http://test.host/attachments/17",
333 "/attachments/17",
325 :class => "thumbnail",
334 :class => "thumbnail",
326 :title => "Cool image")
335 :title => "Cool image")
327 assert_equal "<p>#{link}</p>",
336 assert_equal "<p>#{link}</p>",
General Comments 0
You need to be logged in to leave comments. Login now