mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-23 23:58:31 -05:00
FEATURE: allow animated thumbnails
This commit is contained in:
parent
be87ada474
commit
bf666f8553
4 changed files with 26 additions and 13 deletions
|
@ -79,19 +79,30 @@ class OptimizedImage < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def self.resize(from, to, width, height, allow_animation=false)
|
||||
from << "[0]" unless allow_animation
|
||||
# NOTE: ORDER is important!
|
||||
instructions = %W{
|
||||
#{from}
|
||||
-background transparent
|
||||
-gravity center
|
||||
-thumbnail #{width}x#{height}^
|
||||
-extent #{width}x#{height}
|
||||
-interpolate bicubic
|
||||
-unsharp 2x0.5+0.7+0
|
||||
-quality 98
|
||||
#{to}
|
||||
}.join(" ")
|
||||
instructions = if allow_animation
|
||||
%W{
|
||||
#{from}
|
||||
-coalesce
|
||||
-gravity center
|
||||
-thumbnail #{width}x#{height}^
|
||||
-extent #{width}x#{height}
|
||||
-layers optimize
|
||||
#{to}
|
||||
}.join(" ")
|
||||
else
|
||||
%W{
|
||||
#{from}[0]
|
||||
-background transparent
|
||||
-gravity center
|
||||
-thumbnail #{width}x#{height}^
|
||||
-extent #{width}x#{height}
|
||||
-interpolate bicubic
|
||||
-unsharp 2x0.5+0.7+0
|
||||
-quality 98
|
||||
#{to}
|
||||
}.join(" ")
|
||||
end
|
||||
|
||||
`convert #{instructions}`
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ class Upload < ActiveRecord::Base
|
|||
|
||||
def create_thumbnail!(width, height)
|
||||
return unless SiteSetting.create_thumbnails?
|
||||
thumbnail = OptimizedImage.create_for(self, width, height)
|
||||
thumbnail = OptimizedImage.create_for(self, width, height, allow_animation: SiteSetting.allow_animated_thumbnails)
|
||||
if thumbnail
|
||||
optimized_images << thumbnail
|
||||
self.width = width
|
||||
|
|
|
@ -975,6 +975,7 @@ en:
|
|||
|
||||
allow_uploaded_avatars: "Allow users to upload custom avatars."
|
||||
allow_animated_avatars: "Allow users to use animated gif avatars. WARNING: run the avatars:refresh rake task after changing this setting."
|
||||
allow_animated_thumbnails: "Generates animated thumbnails of animated gifs."
|
||||
automatically_download_gravatars: "Download Gravatars for users upon account creation or email change."
|
||||
digest_topics: "The maximum number of topics to display in the email digest."
|
||||
digest_min_excerpt_length: "Minimum post excerpt in the email digest, in characters."
|
||||
|
|
|
@ -478,6 +478,7 @@ files:
|
|||
allow_animated_avatars:
|
||||
client: true
|
||||
default: false
|
||||
allow_animated_thumbnails: false
|
||||
|
||||
trust:
|
||||
default_trust_level:
|
||||
|
|
Loading…
Reference in a new issue