From 12b37ae754b76bdf88f9a3ac134f7072c6987bf9 Mon Sep 17 00:00:00 2001 From: Go MAEDA Date: Mon, 9 Jul 2018 14:29:38 +0000 Subject: Remove filename from attachment preview links (#27822). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Patch by Felix Schäfer and Gregor Schmidt. git-svn-id: http://svn.redmine.org/redmine/trunk@17440 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/helpers/application_helper.rb | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'app/helpers') 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 ) -- cgit v1.2.3