Class: ImageUploader

Inherits:
CarrierWave::Uploader::Base
  • Object
show all
Includes:
CarrierWave::RMagick
Defined in:
app/uploaders/image_uploader.rb

Direct Known Subclasses

FeatureImageUploader, ProfilePictureUploader

Instance Method Summary collapse

Instance Method Details

#cache_dirObject

Override the directory where uploaded files will be stored. This is a sensible default for uploaders that are meant to be mounted: def store_dir

"uploads/#{Rails.env}/#{model.class.to_s.underscore}/#{model.id}"

end



19
20
21
# File 'app/uploaders/image_uploader.rb', line 19

def cache_dir
 Rails.root.join 'tmp/uploads'
end

#cropObject

version :tiny do

process :resize_to_fit => [25, 25]

end



45
46
47
48
49
50
51
52
53
54
55
56
# File 'app/uploaders/image_uploader.rb', line 45

def crop
  if model.crop_x.present?
    resize_to_limit(540, 540)
    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!(x, y, w, h)
    end
  end
end