aboutsummaryrefslogtreecommitdiffstats
path: root/app/uploaders
diff options
context:
space:
mode:
authorZog2018-05-03 16:42:28 +0200
committerZog2018-05-03 16:42:28 +0200
commit581dbb024db288dc70713af3c5b5052b453412a9 (patch)
treee157880fe365b853659fa0fae95aef91d74ae756 /app/uploaders
parentdb65c0ffc7ccc76a144689ec3db43fbc2e61ee82 (diff)
downloadchouette-core-6092-update-custom-fields.tar.bz2
Refs #6092; Add specs on CustomlFields6092-update-custom-fields
- Show validation errors on fields - Smarter attachments
Diffstat (limited to 'app/uploaders')
-rw-r--r--app/uploaders/custom_field_attachment_uploader.rb26
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