From 79ef8b3653a6ff7edbc1af0741dff36522262c07 Mon Sep 17 00:00:00 2001 From: Yamagishi Kazutoshi Date: Thu, 18 May 2017 22:43:10 +0900 Subject: Fetch remote image using http.rb (#3114) --- app/models/media_attachment.rb | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'app/models/media_attachment.rb') diff --git a/app/models/media_attachment.rb b/app/models/media_attachment.rb index 3277eb227..c29a66eb2 100644 --- a/app/models/media_attachment.rb +++ b/app/models/media_attachment.rb @@ -46,6 +46,9 @@ class MediaAttachment < ApplicationRecord styles: ->(f) { file_styles f }, processors: ->(f) { file_processors f }, convert_options: { all: '-quality 90 -strip' } + + include Remotable + validates_attachment_content_type :file, content_type: IMAGE_MIME_TYPES + VIDEO_MIME_TYPES validates_attachment_size :file, less_than: 8.megabytes @@ -59,10 +62,6 @@ class MediaAttachment < ApplicationRecord remote_url.blank? end - def file_remote_url=(url) - self.file = URI.parse(Addressable::URI.parse(url).normalize.to_s) - end - def to_param shortcode end -- cgit