Use an options hash instead of boolean parameters
This commit is contained in:
parent
c279792130
commit
e593d68beb
|
@ -46,13 +46,10 @@ class Upload < ActiveRecord::Base
|
||||||
thumbnail(width, height).present?
|
thumbnail(width, height).present?
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_thumbnail!(width, height, crop = false)
|
def create_thumbnail!(width, height, opts = nil)
|
||||||
return unless SiteSetting.create_thumbnails?
|
return unless SiteSetting.create_thumbnails?
|
||||||
|
opts ||= {}
|
||||||
opts = {
|
opts[:allow_animation] = SiteSetting.allow_animated_thumbnails
|
||||||
allow_animation: SiteSetting.allow_animated_thumbnails,
|
|
||||||
crop: crop
|
|
||||||
}
|
|
||||||
|
|
||||||
if get_optimized_image(width, height, opts)
|
if get_optimized_image(width, height, opts)
|
||||||
save(validate: false)
|
save(validate: false)
|
||||||
|
|
|
@ -322,14 +322,14 @@ class CookedPostProcessor
|
||||||
end
|
end
|
||||||
|
|
||||||
if upload = Upload.get_from_url(src)
|
if upload = Upload.get_from_url(src)
|
||||||
upload.create_thumbnail!(width, height, crop)
|
upload.create_thumbnail!(width, height, crop: crop)
|
||||||
|
|
||||||
each_responsive_ratio do |ratio|
|
each_responsive_ratio do |ratio|
|
||||||
resized_w = (width * ratio).to_i
|
resized_w = (width * ratio).to_i
|
||||||
resized_h = (height * ratio).to_i
|
resized_h = (height * ratio).to_i
|
||||||
|
|
||||||
if upload.width && resized_w <= upload.width
|
if upload.width && resized_w <= upload.width
|
||||||
upload.create_thumbnail!(resized_w, resized_h, crop)
|
upload.create_thumbnail!(resized_w, resized_h, crop: crop)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue