Sha256: 642ff0d78ffcfb90f7d68dfddd8ff178f02841fc02588396ee27e222b716c577

Contents?: true

Size: 1.15 KB

Versions: 25

Compression:

Stored size: 1.15 KB

Contents

# frozen_string_literal: true

module Blacklight
  module Document
    # Render the thumbnail for the document
    class ThumbnailComponent < Blacklight::Component
      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 ||= helpers.document_presenter(@document)
      end
    end
  end
end

Version data entries

25 entries across 25 versions & 2 rubygems

Version Path
blacklight-7.40.0 app/components/blacklight/document/thumbnail_component.rb
blacklight-7.39.0 app/components/blacklight/document/thumbnail_component.rb
blacklight-7.38.0 app/components/blacklight/document/thumbnail_component.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/blacklight-7.37.0/app/components/blacklight/document/thumbnail_component.rb
blacklight-7.37.0 app/components/blacklight/document/thumbnail_component.rb
blacklight-7.36.2 app/components/blacklight/document/thumbnail_component.rb
blacklight-7.36.1 app/components/blacklight/document/thumbnail_component.rb
blacklight-7.36.0 app/components/blacklight/document/thumbnail_component.rb
blacklight-7.35.0 app/components/blacklight/document/thumbnail_component.rb
blacklight-7.34.0 app/components/blacklight/document/thumbnail_component.rb
blacklight-7.33.1 app/components/blacklight/document/thumbnail_component.rb
blacklight-7.33.0 app/components/blacklight/document/thumbnail_component.rb
blacklight-7.32.0 app/components/blacklight/document/thumbnail_component.rb
blacklight-7.31.0 app/components/blacklight/document/thumbnail_component.rb
blacklight-7.30.0 app/components/blacklight/document/thumbnail_component.rb
blacklight-7.29.0 app/components/blacklight/document/thumbnail_component.rb
blacklight-7.28.0 app/components/blacklight/document/thumbnail_component.rb
blacklight-7.27.1 app/components/blacklight/document/thumbnail_component.rb
blacklight-7.27.0 app/components/blacklight/document/thumbnail_component.rb
blacklight-7.26.1 app/components/blacklight/document/thumbnail_component.rb