I'm using carrierwave and rmagick to handle my image uploads. I now added a new version (smallthumb) to my image_uploader.eb:
class ImageUploader < CarrierWave::Uploader::Base
include CarrierWave::RMagick
storage :file
def store_dir
"uploads/images"
end
version :thumb do
process :resize_to_fill => [250, 250]
end
version :smallthumb do
process :resize_to_fill => [70, 70]
end
def extension_white_list
%w(jpg jpeg gif png)
end
end
I have a model called "image" with the image uploader mounted:
class Image < ActiveRecord::Base
attr_accessible :date, :description, :name, :size, :image, :article_ids
has_and_belongs_to_many :articles
mount_uploader :image, ImageUploader
end
I have read that I need to call recreate_versions!, but I do not understand where I need to call this operation and how. I have my images on the live server in public/uploads/images. How can I recreate the versions of all these images (on my development machine and the live server) so that I have the smallthumb version of the image too?
Image.all.each { |i| i.image.recreate_versions! }
Suppose user model
has an image uploader
.
then try this
user.all.each {|x|x.image.recreate_versions!}
OR
User.all.each do |user|
user.avatar.recreate_versions!
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With