Reputation: 3017
So I got my Carrierwave Uploader which is pretty normal:
class ThumbFileUploader < CarrierWave::Uploader::Base
def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
process :resize_to_limit => [2000, 480]
end
In my model I got:
article.remote_thumbnail_url = article.picture_url
What I want to do is
What's the best practice to accomplish that?
Upvotes: 0
Views: 791
Reputation: 1612
I have had exactly the same problem.
You basically need to have your model store the original image dimensions when the file is first uploaded. You can then use these with jCrop to control the cropping process.
My carrier wave uploaded as this function
def get_geometry
if (@file)
img = ::Magick::Image::read(@file.file).first
@geometry = [ img.columns, img.rows ]
end
end
You have to do rather a lot in the Model, the uploader and in your views.
A full write up is on my web site at the link below.
Upvotes: 1