Support animated PNGs in media attachments (#28516)
This commit is contained in:
parent
39364346bb
commit
a70ae28644
11 changed files with 123 additions and 183 deletions
20
lib/paperclip/gifv_transcoder.rb
Normal file
20
lib/paperclip/gifv_transcoder.rb
Normal file
|
@ -0,0 +1,20 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Paperclip
|
||||
# This transcoder is only to be used for the MediaAttachment model
|
||||
# to convert animated GIFs and PNGs to videos
|
||||
|
||||
class GifvTranscoder < Paperclip::Processor
|
||||
def make
|
||||
final_file = Paperclip::Transcoder.make(file, options, attachment)
|
||||
|
||||
if options[:style] == :original
|
||||
attachment.instance.file_file_name = "#{File.basename(attachment.instance.file_file_name, '.*')}.mp4"
|
||||
attachment.instance.file_content_type = 'video/mp4'
|
||||
attachment.instance.type = MediaAttachment.types[:gifv]
|
||||
end
|
||||
|
||||
final_file
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue