Class: Spina::Image

Inherits:
ApplicationRecord show all
Defined in:
app/models/spina/image.rb

Instance Method Summary collapse

Instance Method Details

#contentObject



25
26
27
# File 'app/models/spina/image.rb', line 25

def content
  self
end

#nameObject



13
14
15
# File 'app/models/spina/image.rb', line 13

def name
  file.try(:filename).to_s
end

#thumbnail(size = '100x100', modifier = '^') ⇒ Object



29
30
31
32
33
34
35
36
37
# File 'app/models/spina/image.rb', line 29

def thumbnail(size = '100x100', modifier = '^')
  variant(
    combine_options: {
      gravity: 'center',
      thumbnail: "#{size}#{modifier}",
      extent: size
    }
  )
end

#variant(options) ⇒ Object



17
18
19
20
21
22
23
# File 'app/models/spina/image.rb', line 17

def variant(options)
  return "" unless file.attached?
  return file if file.content_type.include?('svg')
  return file unless file.variable?

  file.variant(options)
end