プロジェクト

全般

プロフィール

Vote #73623

未完了

url for thubms attachments ignores :only_path

Admin Redmine さんがほぼ2年前に追加. ほぼ2年前に更新.

ステータス:
New
優先度:
通常
担当者:
-
カテゴリ:
Attachments_19
対象バージョン:
-
開始日:
2022/05/09
期日:
進捗率:

0%

予定工数:
category_id:
19
version_id:
0
issue_org_id:
13554
author_id:
4
assigned_to_id:
0
comments:
3
status_id:
1
tracker_id:
1
plus1:
0
affected_version:
closed_on:
affected_version_id:
ステータス-->[New]

説明

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)

journals

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

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

the correct one should be

<pre>
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
</pre>


--------------------------------------------------------------------------------

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

<pre><code class="diff">
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
</code></pre>
--------------------------------------------------------------------------------

Admin Redmine さんがほぼ2年前に更新

  • カテゴリAttachments_19 にセット

他の形式にエクスポート: Atom PDF

いいね!0
いいね!0