posts: fix Download link not respecting tagged filenames option.

Fix bug reported in forum #182766:

    The Download button on the posts page does not respect the Disable
    tagged filenames user setting. Tags are included in the filename when
    clicking the Download button even when the Disable tagged filenames
    setting is set to Yes. Right click -> Save As on the image still
    respects the setting.
This commit is contained in:
evazion
2021-03-20 02:14:23 -05:00
parent 92225177a8
commit fd09cc5e96
3 changed files with 15 additions and 3 deletions

View File

@@ -14,7 +14,11 @@ class PostPresenter
@humanized_essential_tag_string ||= tag_set_presenter.humanized_essential_tag_string.presence || "##{@post.id}"
end
def filename_for_download
"#{humanized_essential_tag_string} - #{@post.md5}.#{@post.file_ext}"
def filename_for_download(current_user)
if current_user.disable_tagged_filenames?
"#{@post.md5}.#{@post.file_ext}"
else
"#{humanized_essential_tag_string} - #{@post.md5}.#{@post.file_ext}"
end
end
end

View File

@@ -17,7 +17,7 @@
</li>
<% if policy(post).visible? %>
<li id="post-option-download">
<%= link_to "Download", post.tagged_file_url + "?download=1", download: post.presenter.filename_for_download %>
<%= link_to "Download", post.tagged_file_url + "?download=1", download: post.presenter.filename_for_download(CurrentUser.user) %>
</li>
<% end %>