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

@@ -304,6 +304,11 @@ class MediaAsset < ApplicationRecord
end
end
# @return [Mime::Type] The file's MIME type.
def mime_type
Mime::Type.lookup_by_extension(file_ext)
end
def file=(file_or_path)
media_file = file_or_path.is_a?(MediaFile) ? file_or_path : MediaFile.open(file_or_path)