Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply video filesize limit to gifv #9924

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions app/models/media_attachment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ class MediaAttachment < ApplicationRecord
convert_options: { all: '-quality 90 -strip' }

validates_attachment_content_type :file, content_type: IMAGE_MIME_TYPES + VIDEO_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
Expand All @@ -111,6 +111,10 @@ def needs_redownload?
file.blank? && remote_url.present?
end

def video_or_gifv?
video? || gifv?
end

def to_param
shortcode
end
Expand Down