mirror of
https://github.com/meineerde/redmine.git
synced 2025-12-19 15:01:14 +00:00
Use relative URL for thumbnails according to :only_path option (#18119).
git-svn-id: http://svn.redmine.org/redmine/trunk@13451 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
6bdef3ca64
commit
c4484a40c0
@ -589,7 +589,7 @@ module ApplicationHelper
|
|||||||
end
|
end
|
||||||
return '' if text.blank?
|
return '' if text.blank?
|
||||||
project = options[:project] || @project || (obj && obj.respond_to?(:project) ? obj.project : nil)
|
project = options[:project] || @project || (obj && obj.respond_to?(:project) ? obj.project : nil)
|
||||||
only_path = options.delete(:only_path) == false ? false : true
|
@only_path = only_path = options.delete(:only_path) == false ? false : true
|
||||||
|
|
||||||
text = text.dup
|
text = text.dup
|
||||||
macros = catch_macros(text)
|
macros = catch_macros(text)
|
||||||
|
|||||||
@ -236,8 +236,8 @@ module Redmine
|
|||||||
size = nil unless size > 0
|
size = nil unless size > 0
|
||||||
if obj && obj.respond_to?(:attachments) && attachment = Attachment.latest_attach(obj.attachments, filename)
|
if obj && obj.respond_to?(:attachments) && attachment = Attachment.latest_attach(obj.attachments, filename)
|
||||||
title = options[:title] || attachment.title
|
title = options[:title] || attachment.title
|
||||||
thumbnail_url = url_for(:controller => 'attachments', :action => 'thumbnail', :id => attachment, :size => size, :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 => false)
|
image_url = url_for(:controller => 'attachments', :action => 'show', :id => attachment, :only_path => @only_path)
|
||||||
|
|
||||||
img = image_tag(thumbnail_url, :alt => attachment.filename)
|
img = image_tag(thumbnail_url, :alt => attachment.filename)
|
||||||
link_to(img, image_url, :class => 'thumbnail', :title => title)
|
link_to(img, image_url, :class => 'thumbnail', :title => title)
|
||||||
|
|||||||
@ -302,26 +302,35 @@ RAW
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_macro_thumbnail
|
def test_macro_thumbnail
|
||||||
link = link_to('<img alt="testfile.PNG" src="http://test.host/attachments/thumbnail/17" />'.html_safe,
|
link = link_to('<img alt="testfile.PNG" src="/attachments/thumbnail/17" />'.html_safe,
|
||||||
"http://test.host/attachments/17",
|
"/attachments/17",
|
||||||
:class => "thumbnail",
|
:class => "thumbnail",
|
||||||
:title => "testfile.PNG")
|
:title => "testfile.PNG")
|
||||||
assert_equal "<p>#{link}</p>",
|
assert_equal "<p>#{link}</p>",
|
||||||
textilizable("{{thumbnail(testfile.png)}}", :object => Issue.find(14))
|
textilizable("{{thumbnail(testfile.png)}}", :object => Issue.find(14))
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_macro_thumbnail_with_size
|
def test_macro_thumbnail_with_full_path
|
||||||
link = link_to('<img alt="testfile.PNG" src="http://test.host/attachments/thumbnail/17/200" />'.html_safe,
|
link = link_to('<img alt="testfile.PNG" src="http://test.host/attachments/thumbnail/17" />'.html_safe,
|
||||||
"http://test.host/attachments/17",
|
"http://test.host/attachments/17",
|
||||||
:class => "thumbnail",
|
:class => "thumbnail",
|
||||||
:title => "testfile.PNG")
|
:title => "testfile.PNG")
|
||||||
|
assert_equal "<p>#{link}</p>",
|
||||||
|
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="/attachments/thumbnail/17/200" />'.html_safe,
|
||||||
|
"/attachments/17",
|
||||||
|
:class => "thumbnail",
|
||||||
|
:title => "testfile.PNG")
|
||||||
assert_equal "<p>#{link}</p>",
|
assert_equal "<p>#{link}</p>",
|
||||||
textilizable("{{thumbnail(testfile.png, size=200)}}", :object => Issue.find(14))
|
textilizable("{{thumbnail(testfile.png, size=200)}}", :object => Issue.find(14))
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_macro_thumbnail_with_title
|
def test_macro_thumbnail_with_title
|
||||||
link = link_to('<img alt="testfile.PNG" src="http://test.host/attachments/thumbnail/17" />'.html_safe,
|
link = link_to('<img alt="testfile.PNG" src="/attachments/thumbnail/17" />'.html_safe,
|
||||||
"http://test.host/attachments/17",
|
"/attachments/17",
|
||||||
:class => "thumbnail",
|
:class => "thumbnail",
|
||||||
:title => "Cool image")
|
:title => "Cool image")
|
||||||
assert_equal "<p>#{link}</p>",
|
assert_equal "<p>#{link}</p>",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user