Files
danbooru/app/presenters/post_presenter.rb
evazion fd09cc5e96 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.
2021-03-20 02:14:23 -05:00

25 lines
648 B
Ruby

class PostPresenter
attr_reader :pool, :next_post_in_pool
delegate :split_tag_list_text, to: :tag_set_presenter
def initialize(post)
@post = post
end
def tag_set_presenter
@tag_set_presenter ||= TagSetPresenter.new(@post.tag_array)
end
def humanized_essential_tag_string
@humanized_essential_tag_string ||= tag_set_presenter.humanized_essential_tag_string.presence || "##{@post.id}"
end
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