diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2019-04-27 03:24:09 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-27 03:24:09 +0200 |
commit | fba96c808d25d2fc35ec63ee6745a1e55a95d707 (patch) | |
tree | 01b9427a5d22fbedf92de37df0488aacb55b7fdc /app/models | |
parent | c008911249a2fc0efaf22b83e51ea8510e67acac (diff) |
Add blurhash (#10630)
* Add blurhash * Use fallback color for spoiler when blurhash missing * Federate the blurhash and accept it as long as it's at most 5x5 * Display unknown media attachments as blurhash placeholders * Improve style of embed actions and spoiler button * Change blurhash resolution from 3x3 to 4x4 * Improve dependency definitions * Fix code style issues
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/media_attachment.rb | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/app/models/media_attachment.rb b/app/models/media_attachment.rb index a57ba0b2e..ab794faa0 100644 --- a/app/models/media_attachment.rb +++ b/app/models/media_attachment.rb @@ -18,6 +18,7 @@ # account_id :bigint(8) # description :text # scheduled_status_id :bigint(8) +# blurhash :string # class MediaAttachment < ApplicationRecord @@ -32,6 +33,11 @@ class MediaAttachment < ApplicationRecord VIDEO_MIME_TYPES = ['video/webm', 'video/mp4', 'video/quicktime'].freeze VIDEO_CONVERTIBLE_MIME_TYPES = ['video/webm', 'video/quicktime'].freeze + BLURHASH_OPTIONS = { + x_comp: 4, + y_comp: 4, + }.freeze + IMAGE_STYLES = { original: { pixels: 1_638_400, # 1280x1280px @@ -41,6 +47,7 @@ class MediaAttachment < ApplicationRecord small: { pixels: 160_000, # 400x400px file_geometry_parser: FastGeometryParser, + blurhash: BLURHASH_OPTIONS, }, }.freeze @@ -53,6 +60,8 @@ class MediaAttachment < ApplicationRecord }, format: 'png', time: 0, + file_geometry_parser: FastGeometryParser, + blurhash: BLURHASH_OPTIONS, }, }.freeze @@ -166,11 +175,11 @@ class MediaAttachment < ApplicationRecord def file_processors(f) if f.file_content_type == 'image/gif' - [:gif_transcoder] + [:gif_transcoder, :blurhash_transcoder] elsif VIDEO_MIME_TYPES.include? f.file_content_type - [:video_transcoder] + [:video_transcoder, :blurhash_transcoder] else - [:lazy_thumbnail] + [:lazy_thumbnail, :blurhash_transcoder] end end end |