Project

General

Profile

Actions

Defect #13554

closed

url for thubms attachments ignores :only_path

Added by Anonymous almost 11 years ago. Updated 9 months ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
Attachments
Target version:
-
Start date:
Due date:
% Done:

0%

Estimated time:
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)

Actions #1

Updated by Anonymous almost 11 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
Actions #2

Updated by Toshi MARUYAMA almost 11 years ago

  • Category set to Attachments
Actions #3

Updated by Go MAEDA over 2 years 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
Actions #4

Updated by Go MAEDA 9 months ago

  • Status changed from New to Closed
Actions

Also available in: Atom PDF