summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2017-07-19 07:00:27 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2017-07-19 07:00:27 +0000
commit85a0e96ad6a5e9cff88301564314c2c96c4c36be (patch)
tree32d9a6763bc402e3b0a0c82cb3112359d03d6bd2
parente90b32c93dda39d9e368c44e4bbc08cd09c240b8 (diff)
downloadredmine-85a0e96ad6a5e9cff88301564314c2c96c4c36be.tar.gz
redmine-85a0e96ad6a5e9cff88301564314c2c96c4c36be.zip
Set a default size for macro thumbnails different from the preview thumbnails.
git-svn-id: http://svn.redmine.org/redmine/trunk@16829 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r--lib/redmine/wiki_formatting/macros.rb5
-rw-r--r--test/unit/lib/redmine/wiki_formatting/macros_test.rb10
2 files changed, 8 insertions, 7 deletions
diff --git a/lib/redmine/wiki_formatting/macros.rb b/lib/redmine/wiki_formatting/macros.rb
index f4700f242..9ef4ffd06 100644
--- a/lib/redmine/wiki_formatting/macros.rb
+++ b/lib/redmine/wiki_formatting/macros.rb
@@ -229,7 +229,8 @@ module Redmine
out
end
- desc "Displays a clickable thumbnail of an attached image. Examples:\n\n" +
+ desc "Displays a clickable thumbnail of an attached image.\n" +
+ "Default size is 200 pixels. Examples:\n\n" +
"{{thumbnail(image.png)}}\n" +
"{{thumbnail(image.png, size=300, title=Thumbnail)}} -- with custom title and size"
macro :thumbnail do |obj, args|
@@ -239,7 +240,7 @@ module Redmine
size = options[:size]
raise 'Invalid size parameter' unless size.nil? || size.match(/^\d+$/)
size = size.to_i
- size = nil unless size > 0
+ size = 200 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 => @only_path)
diff --git a/test/unit/lib/redmine/wiki_formatting/macros_test.rb b/test/unit/lib/redmine/wiki_formatting/macros_test.rb
index 8b6f44974..70e30ef88 100644
--- a/test/unit/lib/redmine/wiki_formatting/macros_test.rb
+++ b/test/unit/lib/redmine/wiki_formatting/macros_test.rb
@@ -307,7 +307,7 @@ RAW
end
def test_macro_thumbnail
- link = link_to('<img alt="testfile.PNG" src="/attachments/thumbnail/17" />'.html_safe,
+ link = link_to('<img alt="testfile.PNG" src="/attachments/thumbnail/17/200" />'.html_safe,
"/attachments/17",
:class => "thumbnail",
:title => "testfile.PNG")
@@ -316,7 +316,7 @@ RAW
end
def test_macro_thumbnail_with_full_path
- link = link_to('<img alt="testfile.PNG" src="http://test.host/attachments/thumbnail/17" />'.html_safe,
+ 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")
@@ -325,16 +325,16 @@ RAW
end
def test_macro_thumbnail_with_size
- link = link_to('<img alt="testfile.PNG" src="/attachments/thumbnail/17/200" />'.html_safe,
+ link = link_to('<img alt="testfile.PNG" src="/attachments/thumbnail/17/400" />'.html_safe,
"/attachments/17",
:class => "thumbnail",
:title => "testfile.PNG")
assert_equal "<p>#{link}</p>",
- textilizable("{{thumbnail(testfile.png, size=200)}}", :object => Issue.find(14))
+ textilizable("{{thumbnail(testfile.png, size=400)}}", :object => Issue.find(14))
end
def test_macro_thumbnail_with_title
- link = link_to('<img alt="testfile.PNG" src="/attachments/thumbnail/17" />'.html_safe,
+ link = link_to('<img alt="testfile.PNG" src="/attachments/thumbnail/17/200" />'.html_safe,
"/attachments/17",
:class => "thumbnail",
:title => "Cool image")