Defect #13554

url for thubms attachments ignores :only_path

Added by Anonymous over 9 years ago. Updated about 1 year ago.

Status:NewStart date:
Priority:NormalDue date:
Assignee:-% Done:


Target version:-
Resolution:Cant reproduce Affected version:


My thumbs attachments url are being generated like this"

  def link_to_attachment(attachment, options={})
    text = options.delete(:text) || attachment.filename
    route_method = options.delete(:download) ? :download_named_attachment_path : :named_attachment_path
    html_options = options.slice!(:only_path)
    url = send(route_method, attachment, attachment.filename, options)
    link_to text, url, html_options

this line have a "!" on end of slice

html_options = options.slice!(:only_path)

should not be without "!" ?

html_options = options.slice(:only_path)


#1 Updated by Anonymous over 9 years ago

So the problemn is the image_tag that concats ActionController::Base.asset_host to thumbs url

  def thumbnail_tag(attachment)
    link_to image_tag(thumbnail_path(attachment)),
      named_attachment_path(attachment, attachment.filename),
      :title => attachment.filename

the correct one should be

  def thumbnail_tag(attachment)
    image_tag = tag(:img, :src =>thumbnail_path(attachment), :alt => attachment.filename)
    link_to image_tag,
      named_attachment_path(attachment, attachment.filename),
      :title => attachment.filename

#2 Updated by Toshi MARUYAMA over 9 years ago

  • Category set to Attachments

#3 Updated by Go MAEDA about 1 year ago

  • Resolution set to Cant reproduce

It seems that AttachmentHelper#link_to_attachment works correctly. In the trunk r21049, application_helper_test.rb with the following patch does not fail.

diff --git a/test/helpers/application_helper_test.rb b/test/helpers/application_helper_test.rb
index 730023443..e50f1ad1e 100644
--- a/test/helpers/application_helper_test.rb
+++ b/test/helpers/application_helper_test.rb
@@ -1746,6 +1746,9 @@ class ApplicationHelperTest < Redmine::HelperTest
       '<a href="">logo.gif</a>',
       link_to_attachment(a, :only_path => false))
+    assert_equal(
+      '<a href="/attachments/3">logo.gif</a>',
+      link_to_attachment(a, :only_path => true))

   def test_thumbnail_tag

Also available in: Atom PDF