Sha256: 35ec6d778d4b9b1f70c789559ad281ffcfa3614aa29d1a0b78d911f14abfd4f9

Contents?: true

Size: 890 Bytes

Versions: 3

Compression:

Stored size: 890 Bytes

Contents

require 'mini_magick'

class ImageUploader < FileUploader
  include CarrierWave::MiniMagick

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

  version :icon, :if=>:create_versions?, :from_version=>:small do
    process :resize_and_pad => [16,16]
  end
  version :small, :if=>:create_versions?, :from_version=>:medium do
    process :resize_to_fit => [75,75]
  end
  version :medium, :if=>:create_versions? do
    process :resize_to_fit => [200,200]
  end
  version :large, :if=>:create_versions? do
    process :resize_to_fit => [500,500]
  end

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


end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
card-1.16.6 mod/05_standard/lib/image_uploader.rb
card-1.16.5 mod/05_standard/lib/image_uploader.rb
card-1.16.4 mod/05_standard/lib/image_uploader.rb