diff options
author | Thibaut Girka <thib@sitedethib.com> | 2019-05-04 16:37:26 +0200 |
---|---|---|
committer | Thibaut Girka <thib@sitedethib.com> | 2019-05-04 16:37:26 +0200 |
commit | 33c80e07838d932efc6214cb1642cefaeb624b67 (patch) | |
tree | 51cae2d9096888cc27ae38ec4b0ceceb1853bb73 /app/models/media_attachment.rb | |
parent | 2c2f649200ba5b742ba9d17ac5ba553c752b59aa (diff) | |
parent | c88d9e524b02cba895de9bdb7cba0e29e37703d5 (diff) |
Merge branch 'master' into glitch-soc/merge-upstream
Conflicts: - app/models/media_attachment.rb
Diffstat (limited to 'app/models/media_attachment.rb')
-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 81397a18e..65f00e1c8 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 @@ -34,6 +35,11 @@ class MediaAttachment < ApplicationRecord VIDEO_CONVERTIBLE_MIME_TYPES = ['video/webm', 'video/quicktime'].freeze AUDIO_MIME_TYPES = ['audio/mpeg', 'audio/mp4', 'audio/vnd.wav', 'audio/wav', 'audio/x-wav', 'audio/x-wave', 'audio/ogg',].freeze + BLURHASH_OPTIONS = { + x_comp: 4, + y_comp: 4, + }.freeze + IMAGE_STYLES = { original: { pixels: 1_638_400, # 1280x1280px @@ -43,6 +49,7 @@ class MediaAttachment < ApplicationRecord small: { pixels: 160_000, # 400x400px file_geometry_parser: FastGeometryParser, + blurhash: BLURHASH_OPTIONS, }, }.freeze @@ -71,6 +78,8 @@ class MediaAttachment < ApplicationRecord }, format: 'png', time: 0, + file_geometry_parser: FastGeometryParser, + blurhash: BLURHASH_OPTIONS, }, }.freeze @@ -186,13 +195,13 @@ 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] elsif AUDIO_MIME_TYPES.include? f.file_content_type [:audio_transcoder] else - [:lazy_thumbnail] + [:lazy_thumbnail, :blurhash_transcoder] end end end |