Sha256: a6426086dc88b3f328519b382a8347d95a38e4c73a097957559386c22ed9b254
Contents?: true
Size: 1.08 KB
Versions: 5
Compression:
Stored size: 1.08 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[show_heading] + %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
5 entries across 5 versions & 1 rubygems