mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Rename ActiveStorage.processor to .variant_processor
This commit is contained in:
parent
ca12968587
commit
f01e249890
7 changed files with 17 additions and 17 deletions
|
@ -13,10 +13,10 @@ require "active_storage/downloading"
|
|||
# {libvips}[http://jcupitt.github.io/libvips/] processor operated by the {ruby-vips}[https://github.com/jcupitt/ruby-vips]
|
||||
# gem).
|
||||
#
|
||||
# Rails.application.config.active_storage.processor
|
||||
# Rails.application.config.active_storage.variant_processor
|
||||
# # => :mini_magick
|
||||
#
|
||||
# Rails.application.config.active_storage.processor = :vips
|
||||
# Rails.application.config.active_storage.variant_processor = :vips
|
||||
# # => :vips
|
||||
#
|
||||
# Note that to create a variant it's necessary to download the entire blob file from the service and load it
|
||||
|
|
|
@ -103,10 +103,10 @@ class ActiveStorage::Variation
|
|||
image.tempfile.tap(&:open)
|
||||
end
|
||||
|
||||
# Returns the ImageProcessing processor class specified by `ActiveStorage.processor`.
|
||||
# Returns the ImageProcessing processor class specified by `ActiveStorage.variant_processor`.
|
||||
def processor
|
||||
require "image_processing"
|
||||
ImageProcessing.const_get(ActiveStorage.processor.to_s.camelize) if ActiveStorage.processor
|
||||
ImageProcessing.const_get(ActiveStorage.variant_processor.to_s.camelize) if ActiveStorage.variant_processor
|
||||
rescue LoadError
|
||||
ActiveSupport::Deprecation.warn("Using mini_magick gem directly is deprecated and will be removed in Rails 6.1. Please add `gem 'image_processing', '~> 1.2'` to your Gemfile.")
|
||||
end
|
||||
|
|
|
@ -45,7 +45,7 @@ module ActiveStorage
|
|||
mattr_accessor :queue
|
||||
mattr_accessor :previewers, default: []
|
||||
mattr_accessor :analyzers, default: []
|
||||
mattr_accessor :processor, default: :mini_magick
|
||||
mattr_accessor :variant_processor, default: :mini_magick
|
||||
mattr_accessor :paths, default: {}
|
||||
mattr_accessor :variable_content_types, default: []
|
||||
mattr_accessor :content_types_to_serve_as_binary, default: []
|
||||
|
|
|
@ -43,12 +43,12 @@ module ActiveStorage
|
|||
|
||||
initializer "active_storage.configs" do
|
||||
config.after_initialize do |app|
|
||||
ActiveStorage.logger = app.config.active_storage.logger || Rails.logger
|
||||
ActiveStorage.queue = app.config.active_storage.queue
|
||||
ActiveStorage.processor = app.config.active_storage.processor || :mini_magick
|
||||
ActiveStorage.previewers = app.config.active_storage.previewers || []
|
||||
ActiveStorage.analyzers = app.config.active_storage.analyzers || []
|
||||
ActiveStorage.paths = app.config.active_storage.paths || {}
|
||||
ActiveStorage.logger = app.config.active_storage.logger || Rails.logger
|
||||
ActiveStorage.queue = app.config.active_storage.queue
|
||||
ActiveStorage.variant_processor = app.config.active_storage.variant_processor || :mini_magick
|
||||
ActiveStorage.previewers = app.config.active_storage.previewers || []
|
||||
ActiveStorage.analyzers = app.config.active_storage.analyzers || []
|
||||
ActiveStorage.paths = app.config.active_storage.paths || {}
|
||||
|
||||
ActiveStorage.variable_content_types = app.config.active_storage.variable_content_types || []
|
||||
ActiveStorage.content_types_to_serve_as_binary = app.config.active_storage.content_types_to_serve_as_binary || []
|
||||
|
|
|
@ -27,7 +27,7 @@ class ActiveStorage::VariantTest < ActiveSupport::TestCase
|
|||
|
||||
test "center-weighted crop of JPEG blob" do
|
||||
begin
|
||||
ActiveStorage.processor = nil
|
||||
ActiveStorage.variant_processor = nil
|
||||
blob = create_file_blob(filename: "racecar.jpg")
|
||||
variant = ActiveSupport::Deprecation.silence do
|
||||
blob.variant(combine_options: {
|
||||
|
@ -42,7 +42,7 @@ class ActiveStorage::VariantTest < ActiveSupport::TestCase
|
|||
assert_equal 100, image.width
|
||||
assert_equal 100, image.height
|
||||
ensure
|
||||
ActiveStorage.processor = :mini_magick
|
||||
ActiveStorage.variant_processor = :mini_magick
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -90,7 +90,7 @@ class ActiveStorage::VariantTest < ActiveSupport::TestCase
|
|||
|
||||
test "works for vips processor" do
|
||||
begin
|
||||
ActiveStorage.processor = :vips
|
||||
ActiveStorage.variant_processor = :vips
|
||||
blob = create_file_blob(filename: "racecar.jpg")
|
||||
variant = blob.variant(thumbnail_image: 100).processed
|
||||
|
||||
|
@ -100,7 +100,7 @@ class ActiveStorage::VariantTest < ActiveSupport::TestCase
|
|||
rescue LoadError
|
||||
# libvips not installed
|
||||
ensure
|
||||
ActiveStorage.processor = :mini_magick
|
||||
ActiveStorage.variant_processor = :mini_magick
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -361,7 +361,7 @@ To switch to the Vips processor, you would add the following to
|
|||
|
||||
```ruby
|
||||
# Use Vips for processing variants.
|
||||
config.active_storage.processor = :vips
|
||||
config.active_storage.variant_processor = :vips
|
||||
```
|
||||
|
||||
Previewing Files
|
||||
|
|
|
@ -778,7 +778,7 @@ normal Rails server.
|
|||
|
||||
`config.active_storage` provides the following configuration options:
|
||||
|
||||
* `config.active_storage.processor` accepts a symbol `:mini_magick` or `:vips`, specifying whether variant transformations will be performed with MiniMagick or ruby-vips. The default is `:mini_magick`.
|
||||
* `config.active_storage.variant_processor` accepts a symbol `:mini_magick` or `:vips`, specifying whether variant transformations will be performed with MiniMagick or ruby-vips. The default is `:mini_magick`.
|
||||
|
||||
* `config.active_storage.analyzers` accepts an array of classes indicating the analyzers available for Active Storage blobs. The default is `[ActiveStorage::Analyzer::ImageAnalyzer, ActiveStorage::Analyzer::VideoAnalyzer]`. The former can extract width and height of an image blob; the latter can extract width, height, duration, angle, and aspect ratio of a video blob.
|
||||
|
||||
|
|
Loading…
Reference in a new issue