Sha256: f81abb544ad982e3e6f1b169d9798fc3235b01cf9ee8ef83c2ccbf8bce8effd5

Contents?: true

Size: 608 Bytes

Versions: 3

Compression:

Stored size: 608 Bytes

Contents

class PageImageSerializer < ActiveModel::Serializer
  include DynamicImage::Helper
  attributes :id, :image_id, :primary, :filename
  attributes :alternative, :caption, :created_at, :url

  def name
    object.image.name
  end

  def alternative
    object.image.alternative
  end

  def caption
    object.image.caption
  end

  def filename
    object.image.filename
  end

  def size
    object.image.crop_size
  end

  def created_at
    object.image.created_at
  end

  def url
    dynamic_image_path(
      object.image,
      size: "2000x2000",
      crop: false,
      upscale: false
    )
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
pages_core-3.4.3 app/serializers/page_image_serializer.rb
pages_core-3.5.1 app/serializers/page_image_serializer.rb
pages_core-3.4.2 app/serializers/page_image_serializer.rb