Defect #13554

url for thubms attachments ignores :only_path

Added by Anonymous over 8 years ago. Updated 4 months ago.

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

0%

Category:Attachments
Target version:-
Resolution:Cant reproduce Affected version:

Description

My thumbs attachments url are being generated like this http://buck-assets-production.s3.amazonaws.com/attachments/thumbnail/"

  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
  end

this line have a "!" on end of slice

html_options = options.slice!(:only_path)

should not be without "!" ?

html_options = options.slice(:only_path)

History

#1 Updated by Anonymous over 8 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
  end

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
  end

#2 Updated by Toshi MARUYAMA over 8 years ago

  • Category set to Attachments

#3 Updated by Go MAEDA 4 months 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
     assert_equal(
       '<a href="http://test.host/attachments/3">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))
   end

   def test_thumbnail_tag

Also available in: Atom PDF