Sha256: 43a2c50a8c46d1088c04a94b29af03fa3dd301c73622ec8389c60576a39d3377

Contents?: true

Size: 908 Bytes

Versions: 1

Compression:

Stored size: 908 Bytes

Contents

# frozen_string_literal: true
require 'dato/local/field_type/file'

module Dato
  module Local
    module FieldType
      class Image < Dato::Local::FieldType::File
        attr_reader :width, :height, :title, :alt

        def self.parse(value, _repo)
          value && new(
            value[:path],
            value[:format],
            value[:size],
            value[:width],
            value[:height],
            value[:alt],
            value[:title]
          )
        end

        def initialize(path, format, size, width, height, alt, title)
          super(path, format, size)
          @width = width
          @height = height
          @alt = alt
          @title = title
        end

        def to_hash(*args)
          super.merge(
            width: width,
            height: height,
            alt: alt,
            title: title
          )
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dato-0.3.13 lib/dato/local/field_type/image.rb