Created
July 20, 2011 14:12
-
-
Save iwasrobbed/1095033 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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