summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorGo MAEDA <maeda@farend.jp>2022-07-19 13:57:04 +0000
committerGo MAEDA <maeda@farend.jp>2022-07-19 13:57:04 +0000
commit20ed193d93f303f5169e5de65e67436b5266da92 (patch)
tree449de4d283547720d7b47b0b305cbbc2716dfbeb /lib
parent34b6581d552a417d67d945ee3d2aaf71177ad15a (diff)
downloadredmine-20ed193d93f303f5169e5de65e67436b5266da92.tar.gz
redmine-20ed193d93f303f5169e5de65e67436b5266da92.zip
Thumbnail macro does not work when a file is attached and preview is displayed immediately (#37379).
Patch by Mizuki ISHIKAWA. git-svn-id: https://svn.redmine.org/redmine/trunk@21716 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'lib')
-rw-r--r--lib/redmine/wiki_formatting/macros.rb8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/redmine/wiki_formatting/macros.rb b/lib/redmine/wiki_formatting/macros.rb
index 0727d6e26..42096b9a3 100644
--- a/lib/redmine/wiki_formatting/macros.rb
+++ b/lib/redmine/wiki_formatting/macros.rb
@@ -278,8 +278,12 @@ module Redmine
size = size.to_i
size = 200 unless size > 0
- if obj && obj.respond_to?(:attachments) &&
- attachment = Attachment.latest_attach(obj.attachments, filename)
+
+ attachments = obj.attachments if obj.respond_to?(:attachments)
+ if (controller_name == 'previews' || action_name == 'preview') && @attachments.present?
+ attachments = (attachments.to_a + @attachments).compact
+ end
+ if attachments.present? && (attachment = Attachment.latest_attach(attachments, filename))
title = options[:title] || attachment.title
thumbnail_url =
url_for(:controller => 'attachments', :action => 'thumbnail',