size = nil unless size > 0
if obj && obj.respond_to?(:attachments) && attachment = Attachment.latest_attach(obj.attachments, filename)
title = options[:title] || attachment.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)
+ thumbnail_url = url_for(:controller => 'attachments', :action => 'thumbnail', :id => attachment, :size => size, :only_path => @only_path)
+ image_url = url_for(:controller => 'attachments', :action => 'show', :id => attachment, :only_path => @only_path)
img = image_tag(thumbnail_url, :alt => attachment.filename)
link_to(img, image_url, :class => 'thumbnail', :title => title)
end
def test_macro_thumbnail
+ link = link_to('<img alt="testfile.PNG" src="/attachments/thumbnail/17" />'.html_safe,
+ "/attachments/17",
+ :class => "thumbnail",
+ :title => "testfile.PNG")
+ assert_equal "<p>#{link}</p>",
+ textilizable("{{thumbnail(testfile.png)}}", :object => Issue.find(14))
+ end
+
+ def test_macro_thumbnail_with_full_path
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>",
- textilizable("{{thumbnail(testfile.png)}}", :object => Issue.find(14))
+ textilizable("{{thumbnail(testfile.png)}}", :object => Issue.find(14), :only_path => false)
end
def test_macro_thumbnail_with_size
- link = link_to('<img alt="testfile.PNG" src="http://test.host/attachments/thumbnail/17/200" />'.html_safe,
- "http://test.host/attachments/17",
+ link = link_to('<img alt="testfile.PNG" src="/attachments/thumbnail/17/200" />'.html_safe,
+ "/attachments/17",
:class => "thumbnail",
:title => "testfile.PNG")
assert_equal "<p>#{link}</p>",
end
def test_macro_thumbnail_with_title
- link = link_to('<img alt="testfile.PNG" src="http://test.host/attachments/thumbnail/17" />'.html_safe,
- "http://test.host/attachments/17",
+ link = link_to('<img alt="testfile.PNG" src="/attachments/thumbnail/17" />'.html_safe,
+ "/attachments/17",
:class => "thumbnail",
:title => "Cool image")
assert_equal "<p>#{link}</p>",