0
0
Fork 0

Fetch remote image using http.rb (#3114)

This commit is contained in:
Yamagishi Kazutoshi 2017-05-18 22:43:10 +09:00 committed by Eugen Rochko
parent b11c4326d2
commit 79ef8b3653
8 changed files with 46 additions and 32 deletions

View file

@ -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