Class: Peoplefinder::ImageUploader
- Inherits:
-
CarrierWave::Uploader::Base
- Object
- CarrierWave::Uploader::Base
- Peoplefinder::ImageUploader
- Includes:
- CarrierWave::DirHelpers, CarrierWave::MiniMagick
- Defined in:
- app/uploaders/peoplefinder/image_uploader.rb
Instance Method Summary collapse
- #crop ⇒ Object
- #default_url ⇒ Object
-
#extension_white_list ⇒ Object
Add a white list of extensions which are allowed to be uploaded.
-
#store_dir ⇒ Object
Override the directory where uploaded files will be stored.
Instance Method Details
#crop ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'app/uploaders/peoplefinder/image_uploader.rb', line 36 def crop if model.crop_x.present? manipulate! do |img| x = model.crop_x.to_i y = model.crop_y.to_i w = model.crop_w.to_i h = model.crop_h.to_i img.crop "#{ w }x#{ h }+#{ x }+#{ y }" img end end end |
#default_url ⇒ Object
22 23 24 |
# File 'app/uploaders/peoplefinder/image_uploader.rb', line 22 def default_url [version_name, 'no_photo.png'].compact.join('_') end |
#extension_white_list ⇒ Object
Add a white list of extensions which are allowed to be uploaded. For images you might use something like this:
51 52 53 |
# File 'app/uploaders/peoplefinder/image_uploader.rb', line 51 def extension_white_list %w[ jpg jpeg gif png ] end |
#store_dir ⇒ Object
Override the directory where uploaded files will be stored. This is a sensible default for uploaders that are meant to be mounted:
13 14 15 16 17 18 19 20 |
# File 'app/uploaders/peoplefinder/image_uploader.rb', line 13 def store_dir '%suploads/%s/%s/%s' % [ base_upload_dir, model.class.to_s.underscore, mounted_as, model.id ] end |