mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 17:46:05 -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
|
end
|
||||||
|
|
||||||
def self.resize(from, to, width, height, allow_animation=false)
|
def self.resize(from, to, width, height, allow_animation=false)
|
||||||
from << "[0]" unless allow_animation
|
|
||||||
# NOTE: ORDER is important!
|
# NOTE: ORDER is important!
|
||||||
instructions = %W{
|
instructions = if allow_animation
|
||||||
#{from}
|
%W{
|
||||||
-background transparent
|
#{from}
|
||||||
-gravity center
|
-coalesce
|
||||||
-thumbnail #{width}x#{height}^
|
-gravity center
|
||||||
-extent #{width}x#{height}
|
-thumbnail #{width}x#{height}^
|
||||||
-interpolate bicubic
|
-extent #{width}x#{height}
|
||||||
-unsharp 2x0.5+0.7+0
|
-layers optimize
|
||||||
-quality 98
|
#{to}
|
||||||
#{to}
|
}.join(" ")
|
||||||
}.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}`
|
`convert #{instructions}`
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ class Upload < ActiveRecord::Base
|
||||||
|
|
||||||
def create_thumbnail!(width, height)
|
def create_thumbnail!(width, height)
|
||||||
return unless SiteSetting.create_thumbnails?
|
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
|
if thumbnail
|
||||||
optimized_images << thumbnail
|
optimized_images << thumbnail
|
||||||
self.width = width
|
self.width = width
|
||||||
|
|
|
@ -975,6 +975,7 @@ en:
|
||||||
|
|
||||||
allow_uploaded_avatars: "Allow users to upload custom avatars."
|
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_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."
|
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_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."
|
digest_min_excerpt_length: "Minimum post excerpt in the email digest, in characters."
|
||||||
|
|
|
@ -478,6 +478,7 @@ files:
|
||||||
allow_animated_avatars:
|
allow_animated_avatars:
|
||||||
client: true
|
client: true
|
||||||
default: false
|
default: false
|
||||||
|
allow_animated_thumbnails: false
|
||||||
|
|
||||||
trust:
|
trust:
|
||||||
default_trust_level:
|
default_trust_level:
|
||||||
|
|
Loading…
Reference in a new issue