mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
parent
140d9c2910
commit
0eacd45ab1
@ -128,9 +128,7 @@ class Upload < ActiveRecord::Base
|
||||
end
|
||||
|
||||
self.width, self.height = size = FastImage.new(path).size
|
||||
if !size.blank?
|
||||
self.thumbnail_width, self.thumbnail_height = ImageSizer.resize(*size)
|
||||
end
|
||||
self.thumbnail_width, self.thumbnail_height = ImageSizer.resize(*size)
|
||||
nil
|
||||
end
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
module ImageSizer
|
||||
|
||||
# Resize an image to the aspect ratio we want
|
||||
def self.resize(width, height, opts = {})
|
||||
def self.resize(width = nil, height = nil, opts = {})
|
||||
return if width.blank? || height.blank?
|
||||
|
||||
max_width = (opts[:max_width] || SiteSetting.max_image_width).to_f
|
||||
|
@ -24,6 +24,10 @@ describe ImageSizer do
|
||||
expect(ImageSizer.resize('100', '101')).to eq([100, 101])
|
||||
end
|
||||
|
||||
it 'returns nil if no width or height are provided' do
|
||||
expect(ImageSizer.resize).to eq(nil)
|
||||
end
|
||||
|
||||
describe 'when larger than the maximum width' do
|
||||
|
||||
before do
|
||||
|
Loading…
Reference in New Issue
Block a user