diff options
author | Go MAEDA <maeda@farend.jp> | 2018-07-09 14:29:38 +0000 |
---|---|---|
committer | Go MAEDA <maeda@farend.jp> | 2018-07-09 14:29:38 +0000 |
commit | 12b37ae754b76bdf88f9a3ac134f7072c6987bf9 (patch) | |
tree | 17f19e8bca1af3e434a926179d9b802a5de9831c /app/helpers | |
parent | 5a2f924b767585f4392da68f80d85a386c4ee6c1 (diff) | |
download | redmine-12b37ae754b76bdf88f9a3ac134f7072c6987bf9.tar.gz redmine-12b37ae754b76bdf88f9a3ac134f7072c6987bf9.zip |
Remove filename from attachment preview links (#27822).
Patch by Felix Schäfer and Gregor Schmidt.
git-svn-id: http://svn.redmine.org/redmine/trunk@17440 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/helpers')
-rw-r--r-- | app/helpers/application_helper.rb | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 576b99647..b7d838034 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -98,10 +98,17 @@ module ApplicationHelper # * :download - Force download (default: false) def link_to_attachment(attachment, options={}) text = options.delete(:text) || attachment.filename - route_method = options.delete(:download) ? :download_named_attachment_url : :named_attachment_url - html_options = options.slice!(:only_path) + if options.delete(:download) + route_method = :download_named_attachment_url + options[:filename] = attachment.filename + else + route_method = :attachment_url + # make sure we don't have an extraneous :filename in the options + options.delete(:filename) + end + html_options = options.slice!(:only_path, :filename) options[:only_path] = true unless options.key?(:only_path) - url = send(route_method, attachment, attachment.filename, options) + url = send(route_method, attachment, options) link_to text, url, html_options end @@ -263,9 +270,8 @@ module ApplicationHelper :srcset => "#{thumbnail_path(attachment, :size => thumbnail_size * 2)} 2x", :style => "max-width: #{thumbnail_size}px; max-height: #{thumbnail_size}px;" ), - named_attachment_path( - attachment, - attachment.filename + attachment_path( + attachment ), :title => attachment.filename ) |