From 78d772af862c536b2e985977b6ba549efe668fe0 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Tue, 6 Mar 2018 06:29:01 +0100 Subject: Fix #3807: Increase avatars to 400x400 max (#6651) But do not upscale when they are smaller --- lib/paperclip/lazy_thumbnail.rb | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'lib/paperclip') 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 -- cgit