posts: remove cropped thumbnails.
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
class MediaAsset < ApplicationRecord
|
||||
class Error < StandardError; end
|
||||
|
||||
VARIANTS = %i[preview crop 180x180 360x360 720x720 sample original]
|
||||
VARIANTS = %i[preview 180x180 360x360 720x720 sample original]
|
||||
ENABLE_SEO_POST_URLS = Danbooru.config.enable_seo_post_urls
|
||||
LARGE_IMAGE_WIDTH = Danbooru.config.large_image_width
|
||||
STORAGE_SERVICE = Danbooru.config.storage_manager
|
||||
@@ -71,8 +71,6 @@ class MediaAsset < ApplicationRecord
|
||||
media_file.preview(width, height, format: :jpeg, quality: 85)
|
||||
in :"720x720"
|
||||
media_file.preview(width, height, format: :webp, quality: 75)
|
||||
in :crop
|
||||
media_file.crop(width, height)
|
||||
in :sample if media_asset.is_ugoira?
|
||||
media_file.convert
|
||||
in :sample if media_asset.is_static_image?
|
||||
@@ -87,7 +85,7 @@ class MediaAsset < ApplicationRecord
|
||||
end
|
||||
|
||||
def file_path(slug = "")
|
||||
if variant.in?(%i[preview crop 180x180 360x360 720x720]) && media_asset.is_flash?
|
||||
if variant.in?(%i[preview 180x180 360x360 720x720]) && media_asset.is_flash?
|
||||
"/images/download-preview.png"
|
||||
else
|
||||
slug = "__#{slug}__" if slug.present?
|
||||
@@ -109,7 +107,7 @@ class MediaAsset < ApplicationRecord
|
||||
# The file extension of this variant.
|
||||
def file_ext
|
||||
case variant
|
||||
when :preview, :crop, :"180x180", :"360x360"
|
||||
when :preview, :"180x180", :"360x360"
|
||||
"jpg"
|
||||
when :"720x720"
|
||||
"webp"
|
||||
@@ -124,8 +122,6 @@ class MediaAsset < ApplicationRecord
|
||||
case variant
|
||||
when :preview
|
||||
[150, 150]
|
||||
when :crop
|
||||
[150, 150]
|
||||
when :"180x180"
|
||||
[180, 180]
|
||||
when :"360x360"
|
||||
@@ -140,12 +136,7 @@ class MediaAsset < ApplicationRecord
|
||||
end
|
||||
|
||||
def dimensions
|
||||
case variant
|
||||
when :crop
|
||||
max_dimensions
|
||||
else
|
||||
MediaFile.scale_dimensions(media_asset.image_width, media_asset.image_height, max_dimensions[0], max_dimensions[1])
|
||||
end
|
||||
MediaFile.scale_dimensions(media_asset.image_width, media_asset.image_height, max_dimensions[0], max_dimensions[1])
|
||||
end
|
||||
|
||||
def width
|
||||
@@ -160,8 +151,6 @@ class MediaAsset < ApplicationRecord
|
||||
case variant
|
||||
when :preview
|
||||
true
|
||||
when :crop
|
||||
true
|
||||
when :"180x180"
|
||||
true
|
||||
when :"360x360"
|
||||
|
||||
@@ -117,10 +117,6 @@ class Post < ApplicationRecord
|
||||
media_asset.variant(:preview).file_url
|
||||
end
|
||||
|
||||
def crop_file_url
|
||||
media_asset.variant(:crop).file_url
|
||||
end
|
||||
|
||||
def open_graph_image_url
|
||||
if is_image?
|
||||
if has_large?
|
||||
@@ -1183,7 +1179,7 @@ class Post < ApplicationRecord
|
||||
|
||||
def purge_cached_urls!
|
||||
urls = [
|
||||
preview_file_url, crop_file_url, large_file_url, file_url,
|
||||
preview_file_url, large_file_url, file_url,
|
||||
tagged_file_url(tagged_filenames: true), tagged_large_file_url(tagged_filenames: true),
|
||||
]
|
||||
|
||||
@@ -1286,7 +1282,7 @@ class Post < ApplicationRecord
|
||||
include PixivMethods
|
||||
include ValidationMethods
|
||||
|
||||
has_bit_flags ["has_embedded_notes", "has_cropped"]
|
||||
has_bit_flags ["has_embedded_notes"]
|
||||
|
||||
def safeblocked?
|
||||
CurrentUser.safe_mode? && (rating != "s" || Danbooru.config.safe_mode_restricted_tags.any? { |tag| tag.in?(tag_array) })
|
||||
|
||||
Reference in New Issue
Block a user