diff options
Diffstat (limited to 'app/models/media_attachment.rb')
-rw-r--r-- | app/models/media_attachment.rb | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/app/models/media_attachment.rb b/app/models/media_attachment.rb index 601b14223..81397a18e 100644 --- a/app/models/media_attachment.rb +++ b/app/models/media_attachment.rb @@ -25,11 +25,11 @@ class MediaAttachment < ApplicationRecord enum type: [:image, :gifv, :video, :audio, :unknown] - IMAGE_FILE_EXTENSIONS = ['.jpg', '.jpeg', '.png', '.gif'].freeze + IMAGE_FILE_EXTENSIONS = ['.jpg', '.jpeg', '.png', '.gif', '.webp'].freeze VIDEO_FILE_EXTENSIONS = ['.webm', '.mp4', '.m4v', '.mov'].freeze AUDIO_FILE_EXTENSIONS = ['.mp3', '.m4a', '.wav', '.ogg'].freeze - IMAGE_MIME_TYPES = ['image/jpeg', 'image/png', 'image/gif'].freeze + IMAGE_MIME_TYPES = ['image/jpeg', 'image/png', 'image/gif', 'image/webp'].freeze VIDEO_MIME_TYPES = ['video/webm', 'video/mp4', 'video/quicktime'].freeze 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 @@ -105,8 +105,8 @@ class MediaAttachment < ApplicationRecord convert_options: { all: '-quality 90 -strip' } validates_attachment_content_type :file, content_type: IMAGE_MIME_TYPES + VIDEO_MIME_TYPES + AUDIO_MIME_TYPES - validates_attachment_size :file, less_than: IMAGE_LIMIT, unless: :video? - validates_attachment_size :file, less_than: VIDEO_LIMIT, if: :video? + validates_attachment_size :file, less_than: IMAGE_LIMIT, unless: :video_or_gifv? + validates_attachment_size :file, less_than: VIDEO_LIMIT, if: :video_or_gifv? remotable_attachment :file, VIDEO_LIMIT include Attachmentable @@ -129,6 +129,10 @@ class MediaAttachment < ApplicationRecord file.blank? && remote_url.present? end + def video_or_gifv? + video? || gifv? + end + def to_param shortcode end |