Class: Spina::Image

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

Instance Method Summary collapse

Methods included from Attachable

#name

Methods inherited from ApplicationRecord

#to_partial_path

Instance Method Details

#contentObject



17
18
19
# File 'app/models/spina/image.rb', line 17

def content
  self
end

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



21
22
23
24
25
26
27
28
29
# File 'app/models/spina/image.rb', line 21

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

#variant(options) ⇒ Object



9
10
11
12
13
14
15
# File 'app/models/spina/image.rb', line 9

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

  file.variant(options)
end