diff options
author | George Claghorn <george.claghorn@gmail.com> | 2018-05-21 11:49:22 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-21 11:49:22 -0400 |
commit | 6c574ac58993512f975ddaf1f679c5956cc576df (patch) | |
tree | 94fdab34c9bcfcba02a3a082f864e8f6107b2d54 /activestorage/app/models/active_storage | |
parent | 41147e3ef802fe7c6aa0eafc9e584fd68f05d395 (diff) | |
parent | 0210ac0b430757f2b5ba5e81f4391e6a37b769a4 (diff) | |
download | rails-6c574ac58993512f975ddaf1f679c5956cc576df.tar.gz rails-6c574ac58993512f975ddaf1f679c5956cc576df.tar.bz2 rails-6c574ac58993512f975ddaf1f679c5956cc576df.zip |
Merge pull request #32936 from jacobsmith/image-variant-allow-disabling-options
[ActiveStorage] Disable variant options when false or nil present
Diffstat (limited to 'activestorage/app/models/active_storage')
-rw-r--r-- | activestorage/app/models/active_storage/variation.rb | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/activestorage/app/models/active_storage/variation.rb b/activestorage/app/models/active_storage/variation.rb index 42f00beb82..806af6366d 100644 --- a/activestorage/app/models/active_storage/variation.rb +++ b/activestorage/app/models/active_storage/variation.rb @@ -66,11 +66,13 @@ class ActiveStorage::Variation # Applies image transformations using the ImageProcessing gem. def image_processing_transform(file, format) operations = transformations.inject([]) do |list, (name, argument)| - if name.to_s == "combine_options" - ActiveSupport::Deprecation.warn("The ImageProcessing ActiveStorage variant backend doesn't need :combine_options, as it already generates a single MiniMagick command. In Rails 6.1 :combine_options will not be supported anymore.") - list.concat argument.to_a - else - list << [name, argument] + list.tap do |list| + if name.to_s == "combine_options" + ActiveSupport::Deprecation.warn("The ImageProcessing ActiveStorage variant backend doesn't need :combine_options, as it already generates a single MiniMagick command. In Rails 6.1 :combine_options will not be supported anymore.") + list.concat argument.keep_if { |key, value| value.present? }.to_a + elsif argument.present? + list << [name, argument] + end end end @@ -116,14 +118,10 @@ class ActiveStorage::Variation end def pass_transform_argument(command, method, argument) - if eligible_argument?(argument) - command.public_send(method, argument) - else + if argument == true command.public_send(method) + elsif argument.present? + command.public_send(method, argument) end end - - def eligible_argument?(argument) - argument.present? && argument != true - end end |