media assets: fix tagged filenames option.
Fix the `enable_seo_post_urls` config option not being respected. This option controls whether filenames in image URLs contain the tags. This option requires URLs rewrites in Nginx to work so it's disabled by default.
This commit is contained in:
@@ -11,16 +11,14 @@
|
||||
class StorageManager
|
||||
class Error < StandardError; end
|
||||
|
||||
attr_reader :base_url, :base_dir, :tagged_filenames
|
||||
attr_reader :base_url, :base_dir
|
||||
|
||||
# Initialize a storage manager object.
|
||||
# @param base_url [String] the base URL where images are stored (ex: "https://cdn.donmai.us/")
|
||||
# @param base_dir [String] the base directory where images are stored (ex: "/var/www/danbooru/public/images")
|
||||
# @param tagged_filenames [Boolean] whether image URLs can include tags
|
||||
def initialize(base_url: nil, base_dir: nil, tagged_filenames: Danbooru.config.enable_seo_post_urls)
|
||||
def initialize(base_url: nil, base_dir: nil)
|
||||
@base_url = base_url.to_s.chomp("/")
|
||||
@base_dir = base_dir.to_s
|
||||
@tagged_filenames = tagged_filenames
|
||||
end
|
||||
|
||||
# Store the given file at the given path. If a file already exists at that
|
||||
|
||||
@@ -67,6 +67,7 @@ class MediaAsset < ApplicationRecord
|
||||
"/images/download-preview.png"
|
||||
else
|
||||
slug = "__#{slug}__" if slug.present?
|
||||
slug = nil if !Danbooru.config.enable_seo_post_urls
|
||||
"/#{variant}/#{md5[0..1]}/#{md5[2..3]}/#{slug}#{file_name}"
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user