class CarrierWave::ImageCardUploader

Adds image specific version handling to {FileCardUploader}. The ImageCardUploader creates five versions of different sizes when it uploads an imagae file: icon (16x16), small (75x75), medium (200X200), large (500x500) and the original size.

Public Instance Methods

full_filename(for_file) click to toggle source

add 'original' if no version is given

Calls superclass method
# File lib/carrier_wave/image_card_uploader.rb, line 49
def full_filename for_file
  name = super(for_file)
  if version_name
    name
  else
    parts = name.split "."
    "#{parts.shift}-original.#{parts.join('.')}"
  end
end
identifier() click to toggle source

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

Calls superclass method
# File lib/carrier_wave/image_card_uploader.rb, line 44
def identifier
  full_filename(super())
end
path(version=nil) click to toggle source
# File lib/carrier_wave/image_card_uploader.rb, line 12
def path version=nil
  version && version != :original ? versions[version].path : super()
end