I have a strange issue. I am trying to use master branch of carrierwave with Rails 3.2.xx project. I need to customize filenames of the versions. But when I add full_filename
method in the version block, my original file also gets reduced to the dimensions specified for version.
When I remove full_filename
method, it all works as expected, but thumb filename has thumb_
prefix which I don't want.
Is there a new way to customize version filenames. I have been using this way successfully in 0.10.0 and before.
Below is my uploader. This is a generated uploader with store_dir
overrides.
class TestUploader < CarrierWave::Uploader::Base
# Include RMagick or MiniMagick support:
# include CarrierWave::RMagick
include CarrierWave::MiniMagick
# Choose what kind of storage to use for this uploader:
# storage :file
storage :fog
# 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/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
# Create different versions of your uploaded files:
version :thumb do
process :resize_to_fit => [200, 200]
def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}/#{version_name}"
end
def full_filename(for_file = model.logo.file)
super(for_file).sub(version_name.to_s + '_', '')
end
end
end
Any ideas? All I need to do is to remove version_name
part from its filename, since I am saving the versions in separate folders. I searched through Wiki and internet, but couldn't find a new way of doing this.
Aucun commentaire:
Enregistrer un commentaire