mirror of
https://github.com/discourse/discourse.git
synced 2025-05-29 01:17:36 +08:00
DEV: Apply syntax_tree formatting to lib/*
This commit is contained in:
@ -1,7 +1,6 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module ImageSizer
|
||||
|
||||
# Resize an image to the aspect ratio we want
|
||||
def self.resize(width, height, opts = {})
|
||||
return if width.blank? || height.blank?
|
||||
@ -12,7 +11,7 @@ module ImageSizer
|
||||
w = width.to_f
|
||||
h = height.to_f
|
||||
|
||||
return [w.floor, h.floor] if w <= max_width && h <= max_height
|
||||
return w.floor, h.floor if w <= max_width && h <= max_height
|
||||
|
||||
ratio = [max_width / w, max_height / h].min
|
||||
[(w * ratio).floor, (h * ratio).floor]
|
||||
@ -27,11 +26,10 @@ module ImageSizer
|
||||
w = width.to_f
|
||||
h = height.to_f
|
||||
|
||||
return [w.floor, h.floor] if w <= max_width && h <= max_height
|
||||
return w.floor, h.floor if w <= max_width && h <= max_height
|
||||
|
||||
ratio = max_width / w
|
||||
|
||||
[[max_width, w].min.floor, [max_height, (h * ratio)].min.floor]
|
||||
end
|
||||
|
||||
end
|
||||
|
Reference in New Issue
Block a user