diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2018-03-06 06:29:01 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-06 06:29:01 +0100 |
commit | 78d772af862c536b2e985977b6ba549efe668fe0 (patch) | |
tree | a3dee3feb504500327d989c3fbd3f97f3d0ffcab | |
parent | e9e475a29d7b5039c8ce14de4cef7e4f54fb7b0e (diff) |
Fix #3807: Increase avatars to 400x400 max (#6651)
But do not upscale when they are smaller
-rw-r--r-- | app/models/concerns/account_avatar.rb | 4 | ||||
-rw-r--r-- | lib/paperclip/lazy_thumbnail.rb | 4 |
2 files changed, 6 insertions, 2 deletions
diff --git a/app/models/concerns/account_avatar.rb b/app/models/concerns/account_avatar.rb index 7712a29fd..9e34a9461 100644 --- a/app/models/concerns/account_avatar.rb +++ b/app/models/concerns/account_avatar.rb @@ -7,8 +7,8 @@ module AccountAvatar class_methods do def avatar_styles(file) - styles = { original: { geometry: '120x120#', file_geometry_parser: FastGeometryParser } } - styles[:static] = { geometry: '120x120#', format: 'png', convert_options: '-coalesce', file_geometry_parser: FastGeometryParser } if file.content_type == 'image/gif' + styles = { original: { geometry: '400x400#', file_geometry_parser: FastGeometryParser } } + styles[:static] = { geometry: '400x400#', format: 'png', convert_options: '-coalesce', file_geometry_parser: FastGeometryParser } if file.content_type == 'image/gif' styles end diff --git a/lib/paperclip/lazy_thumbnail.rb b/lib/paperclip/lazy_thumbnail.rb index 42f9a557a..aafa21343 100644 --- a/lib/paperclip/lazy_thumbnail.rb +++ b/lib/paperclip/lazy_thumbnail.rb @@ -4,6 +4,10 @@ module Paperclip class LazyThumbnail < Paperclip::Thumbnail def make return File.open(@file.path) unless needs_convert? + + min_side = [@current_geometry.width, @current_geometry.height].min + options[:geometry] = "#{min_side.to_i}x#{min_side.to_i}#" if @target_geometry.square? && min_side < @target_geometry.width + Paperclip::Thumbnail.make(file, options, attachment) end |