Feature #27822 » 27822.patch
| app/helpers/application_helper.rb | ||
|---|---|---|
| 98 | 98 |
# * :download - Force download (default: false) |
| 99 | 99 |
def link_to_attachment(attachment, options={})
|
| 100 | 100 |
text = options.delete(:text) || attachment.filename |
| 101 |
route_method = options.delete(:download) ? :download_named_attachment_url : :named_attachment_url |
|
| 102 |
html_options = options.slice!(:only_path) |
|
| 101 |
if options.delete(:download) |
|
| 102 |
route_method = :download_named_attachment_url |
|
| 103 |
options[:filename] = attachment.filename |
|
| 104 |
else |
|
| 105 |
route_method = :attachment_url |
|
| 106 |
# make sure we don't have an extraneous :filename in the options |
|
| 107 |
options.delete(:filename) |
|
| 108 |
end |
|
| 109 |
html_options = options.slice!(:only_path, :filename) |
|
| 103 | 110 |
options[:only_path] = true unless options.key?(:only_path) |
| 104 |
url = send(route_method, attachment, attachment.filename, options)
|
|
| 111 |
url = send(route_method, attachment, options) |
|
| 105 | 112 |
link_to text, url, html_options |
| 106 | 113 |
end |
| 107 | 114 | |
| ... | ... | |
| 229 | 236 |
:srcset => "#{thumbnail_path(attachment, :size => thumbnail_size * 2)} 2x",
|
| 230 | 237 |
:style => "max-width: #{thumbnail_size}px; max-height: #{thumbnail_size}px;"
|
| 231 | 238 |
), |
| 232 |
named_attachment_path( |
|
| 233 |
attachment, |
|
| 234 |
attachment.filename |
|
| 239 |
attachment_path( |
|
| 240 |
attachment |
|
| 235 | 241 |
), |
| 236 | 242 |
:title => attachment.filename |
| 237 | 243 |
) |