Sha256: dc7241727f32b61c6903f61076322bd5673152fae4e380293d228e269c9083ca

Contents?: true

Size: 988 Bytes

Versions: 7

Compression:

Stored size: 988 Bytes

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:, counter:, image_options: {})
        @presenter = presenter
        @counter = counter
        @image_options = { alt: '' }.merge(image_options)
        @use_thumbnail_tag = !@presenter.thumbnail.instance_of?(Blacklight::ThumbnailPresenter)
      end

      def render?
        @presenter.thumbnail.exists?
      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
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
blacklight-7.17.2 app/components/blacklight/document/thumbnail_component.rb
blacklight-7.17.1 app/components/blacklight/document/thumbnail_component.rb
blacklight-7.17.0 app/components/blacklight/document/thumbnail_component.rb
blacklight-7.16.0 app/components/blacklight/document/thumbnail_component.rb
blacklight-7.15.2 app/components/blacklight/document/thumbnail_component.rb
blacklight-7.15.1 app/components/blacklight/document/thumbnail_component.rb
blacklight-7.15.0 app/components/blacklight/document/thumbnail_component.rb