diff options
Diffstat (limited to 'app/uploaders')
| -rw-r--r-- | app/uploaders/custom_field_attachment_uploader.rb | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/app/uploaders/custom_field_attachment_uploader.rb b/app/uploaders/custom_field_attachment_uploader.rb index 411b65bc3..94a14f7e4 100644 --- a/app/uploaders/custom_field_attachment_uploader.rb +++ b/app/uploaders/custom_field_attachment_uploader.rb @@ -1,5 +1,5 @@ class CustomFieldAttachmentUploader < CarrierWave::Uploader::Base - + include CarrierWave::RMagick storage :file def store_dir @@ -9,4 +9,28 @@ class CustomFieldAttachmentUploader < CarrierWave::Uploader::Base def extension_whitelist model.send "#{mounted_as}_extension_whitelist" end + + process :dynamic_versions + + def method_missing mid, *args + unless @dynamic_versions_loaded + dynamic_versions + @versions = nil + cache! + end + send mid, *args + end + + def dynamic_versions + custom_field = model.custom_fields[mounted_as.to_s.gsub('custom_field_', '').to_sym] + _versions = custom_field.options["versions"] || {} + + _versions.each do |name, size| + size = size.split('x') + self.class.version name do + process :resize_to_fit => size + end + end + @dynamic_versions_loaded = true + end end |
