Sha256: 1505aaf49a04278508d622bbed81911f9414314d0a7295a4d773438bf8ef824c

Contents?: true

Size: 794 Bytes

Versions: 28

Compression:

Stored size: 794 Bytes

Contents

# frozen_string_literal: true

class Image < ApplicationRecord
  include DynamicImage::Model
  include PagesCore::Sweepable

  validate :ensure_max_size, on: :create

  localizable do
    attribute :alternative
    attribute :caption
  end

  def byline
    ActiveSupport::Deprecation.warn "Image#byline is deprecated, use #caption"
    caption
  end

  def byline?
    ActiveSupport::Deprecation.warn "Image#byline? is deprecated, use #caption?"
    caption?
  end

  def byline=(new_caption)
    ActiveSupport::Deprecation.warn "Image#byline= is deprecated, use #caption="
    self.caption = new_caption
  end

  private

  def ensure_max_size
    return unless real_width? && real_height?
    return if real_width * real_height <= 48_000_000

    errors.add(:data, "is too large")
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
pages_core-3.15.4 app/models/image.rb
pages_core-3.15.3 app/models/image.rb
pages_core-3.15.2 app/models/image.rb
pages_core-3.15.1 app/models/image.rb
pages_core-3.14.0 app/models/image.rb
pages_core-3.13.0 app/models/image.rb
pages_core-3.12.7 app/models/image.rb
pages_core-3.12.6 app/models/image.rb
pages_core-3.12.5 app/models/image.rb
pages_core-3.12.4 app/models/image.rb
pages_core-3.12.3 app/models/image.rb
pages_core-3.12.2 app/models/image.rb
pages_core-3.12.1 app/models/image.rb
pages_core-3.12.0 app/models/image.rb
pages_core-3.11.3 app/models/image.rb
pages_core-3.11.2 app/models/image.rb
pages_core-3.11.1 app/models/image.rb
pages_core-3.11.0 app/models/image.rb
pages_core-3.10.2 app/models/image.rb
pages_core-3.10.1 app/models/image.rb