Class: Spree::Image

Inherits:
Asset
  • Object
show all
Includes:
Core::S3Support
Defined in:
app/models/spree/image.rb

Instance Method Summary collapse

Instance Method Details

#find_dimensionsObject


31
32
33
34
35
36
37
38
# File 'app/models/spree/image.rb', line 31

def find_dimensions
  temporary = attachment.queued_for_write[:original]
  filename = temporary.path unless temporary.nil?
  filename = attachment.path if filename.blank?
  geometry = Paperclip::Geometry.from_file(filename)
  self.attachment_width  = geometry.width
  self.attachment_height = geometry.height
end

#mini_urlObject

used by admin products autocomplete


27
28
29
# File 'app/models/spree/image.rb', line 27

def mini_url
  attachment.url(:mini, false)
end

#no_attachment_errorsObject

if there are errors from the plugin, then add a more meaningful message


41
42
43
44
45
46
47
48
# File 'app/models/spree/image.rb', line 41

def no_attachment_errors
  unless attachment.errors.empty?
    # uncomment this to get rid of the less-than-useful interrim messages
    # errors.clear
    errors.add :attachment, "Paperclip returned errors for file '#{attachment_file_name}' - check ImageMagick installation or image source file."
    false
  end
end