]> cat aescling's git repositories - mastodon.git/commitdiff
Fix #3807: Increase avatars to 400x400 max (#6651)
authorEugen Rochko <eugen@zeonfederated.com>
Tue, 6 Mar 2018 05:29:01 +0000 (06:29 +0100)
committerGitHub <noreply@github.com>
Tue, 6 Mar 2018 05:29:01 +0000 (06:29 +0100)
But do not upscale when they are smaller

app/models/concerns/account_avatar.rb
lib/paperclip/lazy_thumbnail.rb

index 7712a29fd08d615d6ac12a280dba52853aa92c82..9e34a9461709e3825222488a2ed17faa8858b488 100644 (file)
@@ -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
 
index 42f9a557ac7c567bd50807f75adfcaa575725090..aafa213439853bf52826fd24f7141c6a995c4949 100644 (file)
@@ -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