Sha256: 76844f7de456bcd8ec273a4b4ed9e8da76ffcb3f9dab922c20222ed6d327b574
Contents?: true
Size: 1.09 KB
Versions: 21
Compression:
Stored size: 1.09 KB
Contents
# frozen_string_literal: true require "active_storage_validations" module Katalyst module Content class Figure < Item has_one_attached :image validates :image, presence: true, content_type: config.image_mime_types, size: { less_than: config.max_image_size.megabytes } default_scope { with_attached_image } def initialize_dup(source) super # if image has changed, duplicate the change, otherwise attach the existing blob if source.attachment_changes["image"] self.image = source.attachment_changes["image"].attachable elsif source.image.attached? && !source.image.marked_for_destruction? image.attach(source.image.blob) end end def self.permitted_params super - %i[heading_style] + %i[image caption] end alias_attribute :alt, :heading def to_plain_text text = ["Image: #{alt}"] text << "Caption: #{caption}" if caption.present? text.compact.join("\n") if visible? end end end end
Version data entries
21 entries across 21 versions & 1 rubygems