media assets: add dynamically-generated thumbnails (owner-only).

Add ability to dynamically generate thumbnails with:

* https://danbooru.donmai.us/media_assets/6961761.jpg?width=180&height=180

This is currently restricted to the Owner-level user because it's slow.
This commit is contained in:
evazion
2022-10-31 22:50:21 -05:00
parent acc511ab7d
commit b41b67af6c
4 changed files with 33 additions and 3 deletions

View File

@@ -147,6 +147,10 @@ class MediaFile
ExifTool.new(file).metadata
end
def mime_type
Mime::Type.lookup_by_extension(file_ext)
end
# @return [Boolean] True if the file is supported by Danbooru. Certain files may be unsupported because they use features we don't support.
def is_supported?
true
@@ -251,8 +255,9 @@ class MediaFile
path: path,
width: width,
height: height,
file_ext: file_ext,
file_size: file_size,
file_ext: file_ext,
mime_type: mime_type,
md5: md5,
is_corrupt?: is_corrupt?,
is_supported?: is_supported?,
@@ -276,5 +281,5 @@ class MediaFile
end
end
memoize :file_ext, :file_size, :md5, :metadata
memoize :file_ext, :file_size, :md5, :metadata, :mime_type
end