1. 21 5月, 2018 1 次提交
    • J
      Disable variant options when false or nil present · 0210ac0b
      Jacob Smith 提交于
      In response to https://github.com/rails/rails/issues/32917
      
      In the current implementation, ActiveStorage passes all options to the underlying processor,
      including when a key has a value of false.
      
      For example, passing:
      
      ```
      avatar.variant(resize: "100x100", monochrome: false, flip: "-90")
      ```
      
      will return a monochrome image (or an error, pending on ImageMagick configuration) because
      it passes `-monochrome false` to the command (but the command line does not allow disabling
      flags this way, as usually a user would omit the flag entirely to disable that feature).
      
      This fix only passes those keys forward to the underlying processor if the value responds to
      `present?`. In practice, this means that `false` or `nil` will be filtered out before going
      to the processor.
      
      One possible use case would be for a user to be able to apply different filters to an avatar.
      The code might look something like:
      
      ```
        variant_options = {
          monochrome: params[:monochrome],
          resize:     params[:resize]
        }
      
        avatar.variant(*variant_options)
      ```
      
      Obviously some sanitization may be beneficial in a real-world scenario, but this type of
      configuration object could be used in many other places as well.
      
      - Add removing falsy values from varaints to changelog
      
      - The entirety of #image_processing_transformation inject block was wrapped in `list.tap`
       to guard against the default `nil` being returned if no conditional was called.
      
      - add test for explicitly true variant options
      0210ac0b
  2. 20 5月, 2018 1 次提交
  3. 19 5月, 2018 6 次提交
  4. 18 5月, 2018 6 次提交
  5. 17 5月, 2018 10 次提交
  6. 16 5月, 2018 2 次提交
  7. 15 5月, 2018 3 次提交
  8. 14 5月, 2018 1 次提交
  9. 13 5月, 2018 7 次提交
  10. 12 5月, 2018 3 次提交