Class: Locomotive::ThemeAssetUploader

Inherits:
BaseUploader show all
Includes:
CarrierWave::Uploader::Asset
Defined in:
app/uploaders/locomotive/theme_asset_uploader.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from CarrierWave::Uploader::Asset

#find_content_type_of_model, #image?, #set_content_type_of_model, #set_size, #set_width_and_height

Methods inherited from CarrierWave::Uploader::Base

#build_store_dir, #to_label, #to_liquid

Methods included from CarrierWave::Uploader::Base64Download

#download!

Class Method Details

.content_typesObject



24
25
26
27
28
29
# File 'app/uploaders/locomotive/theme_asset_uploader.rb', line 24

def self.content_types
  # pdf is not considered as a custom content type for theme assets.
  list = super.clone
  list.delete(:pdf)
  list
end

Instance Method Details

#apply_content_type_exception(value) ⇒ Object



16
17
18
19
20
21
22
# File 'app/uploaders/locomotive/theme_asset_uploader.rb', line 16

def apply_content_type_exception(value)
  if content_type == 'image/svg+xml' && model.folder.starts_with?('fonts')
    :font
  else
    value
  end
end

#extension_whitelistObject



12
13
14
# File 'app/uploaders/locomotive/theme_asset_uploader.rb', line 12

def extension_whitelist
  %w(jpg jpeg gif png css js swf flv mp4 eot svg svgz ttf ttc woff woff2 otf ico htc map html cur txt xml json ogv)
end

#store_dirObject



8
9
10
# File 'app/uploaders/locomotive/theme_asset_uploader.rb', line 8

def store_dir
  self.build_store_dir('sites', model.site_id, 'theme', model.folder)
end