module CarrierWave::Uploader::Processing::ClassMethods
def process(*args)
end
end
...
def disallowed_image_type?
end
...
def image?
end
...
def scale(height, width)
end
...
def vignette
end
...
def sepiatone
process :sepiatone, :if => :image?
process :scale => [200, 200], :unless => :disallowed_image_type?
process :scale => [200, 200], :if => :image?
process :scale => [200, 200]
process :sepiatone, :vignette
class MyUploader < CarrierWave::Uploader::Base
=== Examples
args (*Symbol, Hash{Symbol => Array[]})
=== Parameters
an array of arguments to call the method with. Also accepts an :if or :unless condition
or a list of such methods, or a hash where the key is a method and the value is
The argument may be the name of any method of the uploader, expressed as a symbol,
Adds a processor callback which applies operations as a file is uploaded.
#
def process(*args) new_processors = args.inject({}) do |hash, arg| arg = { arg => [] } unless arg.is_a?(Hash) hash.merge!(arg) end condition_type = new_processors.keys.detect { |key| [:if, :unless].include?(key) } condition = new_processors.delete(:if) || new_processors.delete(:unless) new_processors.each do |processor, processor_args| self.processors += [[processor, processor_args, condition, condition_type]] if processor == :convert # Treat :convert specially, since it should trigger the file extension change force_extension processor_args if condition warn "Use of 'process convert: format' with conditionals has an issue and doesn't work correctly. See https://github.com/carrierwaveuploader/carrierwave/issues/2723 for details. " end end end end