Module: Spree::Image::PaperclipAttachment
- Extended by:
- ActiveSupport::Concern
- Defined in:
- app/models/spree/image/paperclip_attachment.rb
Instance Method Summary collapse
- #attachment_present? ⇒ Boolean
- #filename ⇒ Object
- #find_dimensions ⇒ Object
-
#no_attachment_errors ⇒ Object
if there are errors from the plugin, then add a more meaningful message.
- #url(size) ⇒ Object
Instance Method Details
#attachment_present? ⇒ Boolean
33 34 35 |
# File 'app/models/spree/image/paperclip_attachment.rb', line 33 def .present? end |
#filename ⇒ Object
29 30 31 |
# File 'app/models/spree/image/paperclip_attachment.rb', line 29 def filename end |
#find_dimensions ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'app/models/spree/image/paperclip_attachment.rb', line 37 def find_dimensions temporary = .queued_for_write[:original] filename = temporary.path unless temporary.nil? filename = .path if filename.blank? geometry = Paperclip::Geometry.from_file(filename) self. = geometry.width self. = geometry.height end |
#no_attachment_errors ⇒ Object
if there are errors from the plugin, then add a more meaningful message
47 48 49 50 51 52 53 54 |
# File 'app/models/spree/image/paperclip_attachment.rb', line 47 def unless .errors.empty? # uncomment this to get rid of the less-than-useful interim messages # errors.clear errors.add :attachment, "Paperclip returned errors for file '#{}' - check ImageMagick installation or image source file." false end end |
#url(size) ⇒ Object
25 26 27 |
# File 'app/models/spree/image/paperclip_attachment.rb', line 25 def url(size) .url(size) end |