Sha256: 7b04b688d20f6a86a304d7dfb761a9f71d1955aab63f4eb9cbc1b54eddc9d0de
Contents?: true
Size: 1.16 KB
Versions: 13
Compression:
Stored size: 1.16 KB
Contents
# frozen_string_literal: true module Blacklight module Document # Render the thumbnail for the document class ThumbnailComponent < ::ViewComponent::Base with_collection_parameter :presenter # @param [Blacklight::DocumentPresenter] presenter # @param [Integer] counter # @param [Hash] image_options options for the thumbnail presenter's image tag def initialize(presenter: nil, document: nil, counter:, image_options: {}) @presenter = presenter @document = presenter&.document || document @counter = counter @image_options = { alt: '' }.merge(image_options) end def render? presenter.thumbnail.exists? end def use_thumbnail_tag_behavior? !presenter.thumbnail.instance_of?(Blacklight::ThumbnailPresenter) end def warn_about_deprecated_behavior Deprecation.warn(Blacklight::Document::ThumbnailComponent, 'Detected as custom thumbnail presenter; make sure it has a #render method that returns just the thumbnail image tag') end def presenter @presenter ||= @view_context.document_presenter(@document) end end end end
Version data entries
13 entries across 13 versions & 1 rubygems