]> cat aescling's git repositories - mastodon.git/commitdiff
Fix animated GIF generates animated thumbnail (#16216)
authorrinsuki <428rinsuki+git@gmail.com>
Tue, 11 May 2021 17:15:11 +0000 (02:15 +0900)
committerGitHub <noreply@github.com>
Tue, 11 May 2021 17:15:11 +0000 (19:15 +0200)
lib/paperclip/gif_transcoder.rb

index 74aa1a0b261608a95dd60266f981bc2e1f5595a1..d14465c018428f24ac79d4e0b7f7ae80dacf069d 100644 (file)
@@ -108,9 +108,11 @@ module Paperclip
 
       final_file = Paperclip::Transcoder.make(file, options, attachment)
 
-      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]
+      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
@@ -118,7 +120,7 @@ module Paperclip
     private
 
     def needs_convert?
-      options[:style] == :original && GifReader.animated?(file.path)
+      GifReader.animated?(file.path)
     end
   end
 end