about summary refs log tree commit diff
diff options
context:
space:
mode:
authorrinsuki <428rinsuki+git@gmail.com>2021-05-12 02:15:11 +0900
committerGitHub <noreply@github.com>2021-05-11 19:15:11 +0200
commit5ed5f62705a0d9dd58f4eb617445683ee8bd2378 (patch)
treec2781dbedad05397efecd9112967447d6c2bed3b
parentbe353bccbbdd932ace6c42fee9d0a0e58330f0d3 (diff)
Fix animated GIF generates animated thumbnail (#16216)
-rw-r--r--lib/paperclip/gif_transcoder.rb10
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/paperclip/gif_transcoder.rb b/lib/paperclip/gif_transcoder.rb
index 74aa1a0b2..d14465c01 100644
--- a/lib/paperclip/gif_transcoder.rb
+++ b/lib/paperclip/gif_transcoder.rb
@@ -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