Module: CarrierWave::Qiniu::Style::ClassMethods

Defined in:
lib/carrierwave/qiniu/style.rb

Instance Method Summary collapse

Instance Method Details

#get_qiniu_stylesObject



42
43
44
# File 'lib/carrierwave/qiniu/style.rb', line 42

def get_qiniu_styles
  @_qiniu_styles
end

#use_qiniu_styles(versions = nil) ⇒ Object

Examples:

CarrierWave.configure do |config|
  config.qiniu_styles = [:thumbnail, :large]
  # or
  config.qiniu_styles = {:thumbnail => 'imageView/0/w/200', :large => 'imageView/0/w/800'}
end

# Eanble qiniu styles otherwise default version processing
# And use default styles
use_qiniu_styles

# Override default styles and use your own styles
use_qniu_styles :thumbnail => 'imageView/0/w/400', :xlarge => 'imageView/0/w/1600'


24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/carrierwave/qiniu/style.rb', line 24

def use_qiniu_styles(versions = nil)

  # Override #url method when set styles, otherwise still default strategy.
  unless include? ::CarrierWave::Qiniu::Url
    send(:include, ::CarrierWave::Qiniu::Url)
  end

  @_qiniu_styles = {}
  if self.qiniu_styles
    # Set default styles
    @_qiniu_styles = parse_qiniu_styles(self.qiniu_styles)
  elsif versions
    # Set custom styles
    self.qiniu_styles = versions
    @_qiniu_styles = parse_qiniu_styles(versions)
  end
end