lib/spontaneous/field/image.rb in spontaneous-0.2.0.beta9 vs lib/spontaneous/field/image.rb in spontaneous-0.2.0.beta10
- old
+ new
@@ -44,16 +44,30 @@
def self.ui_preview_size
[ {}, proc { width 300 } ]
end
+ def self.default_attributes
+ @default_attributes ||= {}
+ end
+
+ def self.default_attributes=(default_attributes = {})
+ @default_attributes = default_attributes
+ end
+
def image?
true
end
+ def blank?
+ original.blank?
+ end
+
def sizes
- @sizes ||= Hash.new { |hash, key| hash[key] = S::Media::Image::Attributes.new(processed_values[key]) }
+ @sizes ||= Hash.new { |hash, key|
+ hash[key] = S::Media::Image::Attributes.new(site, processed_values[key])
+ }
end
# value used to show conflicts between the current value and the value they're attempting to enter
def conflicted_value
value
@@ -91,10 +105,14 @@
def src
original.src
end
+ def url
+ original.url
+ end
+
def filepath
unprocessed_value
end
# formats are irrelevant to image/file fields
@@ -120,11 +138,15 @@
size.generate
end
def export(user = nil)
+ processed = Hash[outputs.map { |size|
+ [size, sizes[size].export(user)]
+ }]
+ processed.update(__pending__: pending_value) if has_pending_value?
super(user).merge({
- :processed_value => processed_values
+ processed_value: processed
})
end
self.register(:image, :photo)
end