Class: DatoDump::FieldTypeDumper::Image

Inherits:
Object
  • Object
show all
Defined in:
lib/dato_dump/field_type_dumper/image.rb

Class Method Summary collapse

Class Method Details

.dump(value, _repo) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/dato_dump/field_type_dumper/image.rb', line 5

def self.dump(value, _repo)
  if value
    url = Imgix::Client.new(
      host: 'dato-images.imgix.net',
      secure: true
    )
      .path(value[:path])
      .ch('DPR', 'Width')
      .auto('compress', 'format')
      .to_url

    {
      format: value[:format],
      size: value[:size],
      width: value[:width],
      height: value[:height],
      url: url
    }
  end
end