support dedicated image servers
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
# donmai.us specific
|
||||
|
||||
require 'base64'
|
||||
require 'digest/md5'
|
||||
|
||||
|
||||
@@ -145,29 +145,16 @@ class Post < ApplicationRecord
|
||||
end
|
||||
|
||||
def file_url
|
||||
if Danbooru.config.use_s3_proxy?(self)
|
||||
"/cached/data/#{seo_tag_string}#{file_path_prefix}#{md5}.#{file_ext}"
|
||||
else
|
||||
"/data/#{seo_tag_string}#{file_path_prefix}#{md5}.#{file_ext}"
|
||||
end
|
||||
"#{Danbooru.config.image_server_host(self)}/data/#{seo_tag_string}#{file_path_prefix}#{md5}.#{file_ext}"
|
||||
end
|
||||
|
||||
# this is for the 640x320 version
|
||||
def cropped_file_url
|
||||
if Danbooru.config.use_s3_proxy?(self)
|
||||
"/cached/data/cropped/large/#{md5}.jpg"
|
||||
else
|
||||
"/data/cropped/large/#{md5}.jpg"
|
||||
end
|
||||
end
|
||||
|
||||
def large_file_url
|
||||
if has_large?
|
||||
if Danbooru.config.use_s3_proxy?(self)
|
||||
"/cached/data/sample/#{seo_tag_string}#{file_path_prefix}#{Danbooru.config.large_image_prefix}#{md5}.#{large_file_ext}"
|
||||
else
|
||||
"/data/sample/#{seo_tag_string}#{file_path_prefix}#{Danbooru.config.large_image_prefix}#{md5}.#{large_file_ext}"
|
||||
end
|
||||
"#{Danbooru.config.image_server_host(self)}/data/sample/#{seo_tag_string}#{file_path_prefix}#{Danbooru.config.large_image_prefix}#{md5}.#{large_file_ext}"
|
||||
else
|
||||
file_url
|
||||
end
|
||||
@@ -190,11 +177,7 @@ class Post < ApplicationRecord
|
||||
return "/images/download-preview.png"
|
||||
end
|
||||
|
||||
# if has_cropped? && !CurrentUser.disable_cropped_thumbnails?
|
||||
# "/cached/data/cropped/small/#{md5}.jpg"
|
||||
# else
|
||||
"/data/preview/#{file_path_prefix}#{md5}.jpg"
|
||||
# end
|
||||
"/data/preview/#{file_path_prefix}#{md5}.jpg"
|
||||
end
|
||||
|
||||
def complete_preview_file_url
|
||||
@@ -204,9 +187,17 @@ class Post < ApplicationRecord
|
||||
def open_graph_image_url
|
||||
if is_image?
|
||||
if has_large?
|
||||
"http://#{Danbooru.config.hostname}#{large_file_url}"
|
||||
if Danbooru.config.image_server_host(self) =~ /http/
|
||||
large_file_url
|
||||
else
|
||||
"http://#{Danbooru.config.hostname}#{large_file_url}"
|
||||
end
|
||||
else
|
||||
"http://#{Danbooru.config.hostname}#{file_url}"
|
||||
if Danbooru.config.image_server_host(self) =~ /http/
|
||||
file_url
|
||||
else
|
||||
"http://#{Danbooru.config.hostname}#{file_url}"
|
||||
end
|
||||
end
|
||||
else
|
||||
complete_preview_file_url
|
||||
|
||||
Reference in New Issue
Block a user