From aa161acc0236dc840c65f6a9ea8a20e1f46ee20d Mon Sep 17 00:00:00 2001 From: Toks Date: Sat, 25 Apr 2015 22:58:18 -0400 Subject: [PATCH] fix #2237 --- app/models/post.rb | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/app/models/post.rb b/app/models/post.rb index d6ea04b19..e89729b1a 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -137,6 +137,14 @@ class Post < ActiveRecord::Base file_ext =~ /jpg|jpeg|gif|png/i end + def is_animated_gif? + if file_ext =~ /gif/i + return Magick::Image.ping(file_path).length > 1 + else + return false + end + end + def is_flash? file_ext =~ /swf/i end @@ -550,7 +558,7 @@ class Post < ActiveRecord::Base def add_automatic_tags(tags) return tags if !Danbooru.config.enable_dimension_autotagging - tags -= %w(incredibly_absurdres absurdres highres lowres huge_filesize flash webm) + tags -= %w(incredibly_absurdres absurdres highres lowres huge_filesize animated_gif flash webm) if has_dimensions? if image_width >= 10_000 || image_height >= 10_000 @@ -579,6 +587,10 @@ class Post < ActiveRecord::Base tags << "huge_filesize" end + if is_animated_gif? + tags << "animated_gif" + end + if is_flash? tags << "flash" end