Reputation: 1385
I was wondering is it possible to store different image versions into different locations.
Let's say I have some private Carrierwave folder defined like this:
def store_dir
"#{Rails.root}/private/uploads/"
end
And a couple of versions of uploaded images:
version :medium do
process :resize_to_limit => [400, 400]
end
version :large do
process :resize_to_limit => [800, 800]
end
version :thumb do
process :resize_to_limit => [200, 200]
end
I would like to store uploaded image, medium version and large version of that image in defined store_path
but would like to have thumb version available to users stored in public folder, for example inside that default public folder:
def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
How can I accomplish that? Thank you!
Upvotes: 4
Views: 717
Reputation: 1585
You just need to override store_dir
inside the version
block. So for your example,
version :medium do
process :resize_to_limit => [400, 400]
end
version :large do
process :resize_to_limit => [800, 800]
end
version :thumb do
process :resize_to_limit => [200, 200]
def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
end
Upvotes: 3
Reputation: 3895
In old version of carrierwave I have used the version_name, I am not sure if it works now
def store_dir
if version_name != 'thumb'
# path for other versions
else
# path for thumb version
end
end
Upvotes: 2