Browse Source

Fix #3807: Increase avatars to 400x400 max (#6651)

But do not upscale when they are smaller
pull/4/head
Eugen Rochko 6 years ago
committed by GitHub
parent
commit
78d772af86
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions
  1. +2
    -2
      app/models/concerns/account_avatar.rb
  2. +4
    -0
      lib/paperclip/lazy_thumbnail.rb

+ 2
- 2
app/models/concerns/account_avatar.rb View 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

+ 4
- 0
lib/paperclip/lazy_thumbnail.rb View 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

Loading…
Cancel
Save