A platform for community discussion. Free, open, simple.
Use an options hash instead of boolean parameters
Robin Warde593d68bebc7
diff --git a/app/models/upload.rb b/app/models/upload.rbindex 350537952c5..3f1f27960c4 100644--- a/app/models/upload.rb+++ b/app/models/upload.rb@@ -46,13 +46,10 @@ class Upload < ActiveRecord::Basethumbnail(width, height).present?end- def create_thumbnail!(width, height, crop = false)+ def create_thumbnail!(width, height, opts = nil)return unless SiteSetting.create_thumbnails?-- opts = {- allow_animation: SiteSetting.allow_animated_thumbnails,- crop: crop- }+ opts ||= {}+ opts[:allow_animation] = SiteSetting.allow_animated_thumbnailsif get_optimized_image(width, height, opts)save(validate: false)diff --git a/lib/cooked_post_processor.rb b/lib/cooked_post_processor.rbindex a8ad6ad1731..7458622c34c 100644--- a/lib/cooked_post_processor.rb+++ b/lib/cooked_post_processor.rb@@ -322,14 +322,14 @@ class CookedPostProcessorendif upload = Upload.get_from_url(src)- upload.create_thumbnail!(width, height, crop)+ upload.create_thumbnail!(width, height, crop: crop)each_responsive_ratio do |ratio|resized_w = (width * ratio).to_iresized_h = (height * ratio).to_iif upload.width && resized_w <= upload.width- upload.create_thumbnail!(resized_w, resized_h, crop)+ upload.create_thumbnail!(resized_w, resized_h, crop: crop)endendend