Skip to content

Instantly share code, notes, and snippets.

@iwasrobbed
Created July 20, 2011 14:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iwasrobbed/1095033 to your computer and use it in GitHub Desktop.
Save iwasrobbed/1095033 to your computer and use it in GitHub Desktop.
class ImageUploader < CarrierWave::Uploader::Base
# include MiniMagick support for resizing images
include CarrierWave::MiniMagick
# Choose what kind of storage to use for this uploader:
# (handled in the initializer file)
# storage :file
# storage :fog
# Override the directory where uploaded files will be stored.
def store_dir
"images/#{model.id}"
end
# Create different versions of your uploaded files:
version :large_profile do
# returns a 100x100 image
process :resize_to_fill => [100, 100]
end
version :medium_profile do
# returns a 50x50 image
process :resize_to_fill => [50, 50]
end
version :small_profile do
# returns a 35x35 image
process :resize_to_fill => [35, 35]
end
# Set the filename for versioned files
def filename
"#{model.id}.jpg" if original_filename
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment