Class: CarrierWave::ImageCardUploader

Inherits:
FileCardUploader show all
Includes:
MiniMagick
Defined in:
mod/carrierwave/lib/carrier_wave/image_card_uploader.rb

Instance Attribute Summary

Attributes inherited from FileCardUploader

#mod

Instance Method Summary collapse

Methods inherited from FileCardUploader

#action_id, #cache_dir, #create_versions?, #db_content, #extension, #file_dir, #filename, #mod_file?, #original_filename, #retrieve_dir, #retrieve_path, #store_dir, #store_path, #tmp_path, #url, #url_filename

Methods included from Card::Env::Location

#card_path, #card_url, #page_path

Instance Method Details

#full_filename(for_file) ⇒ Object

add 'original' if no version is given



44
45
46
47
48
49
50
51
52
# File 'mod/carrierwave/lib/carrier_wave/image_card_uploader.rb', line 44

def full_filename for_file
  name = super(for_file)
  if version_name
    name
  else
    parts = name.split "."
    "#{parts.shift}-original.#{parts.join('.')}"
  end
end

#identifierObject

version :small_square, if: :create_versions?, from_version: :medium_square do process resize_to_fill: [75, 75] end version :medium_square, if: :create_versions? do process resize_to_fill: [200, 200] end

In case we decide to support the squared versions we have to update all existing images with the following snippet: Card.search(type_id: Card::ImageID) do |card| card.image.cache_stored_file! card.image.recreate_versions! end



39
40
41
# File 'mod/carrierwave/lib/carrier_wave/image_card_uploader.rb', line 39

def identifier
  full_filename(super())
end

#path(version = nil) ⇒ Object



7
8
9
# File 'mod/carrierwave/lib/carrier_wave/image_card_uploader.rb', line 7

def path version=nil
  (version && version != :original) ? versions[version].path : super()
end