Class: Blacklight::Document::ThumbnailComponent
- Inherits:
-
Component
- Object
- ViewComponent::Base
- Component
- Blacklight::Document::ThumbnailComponent
show all
- Defined in:
- app/components/blacklight/document/thumbnail_component.rb
Overview
Render the thumbnail for the document
Instance Method Summary
collapse
Methods inherited from Component
reset_compiler!, sidecar_files, upstream_sidecar_files
Constructor Details
#initialize(presenter: nil, document: nil, counter:, image_options: {}) ⇒ ThumbnailComponent
Returns a new instance of ThumbnailComponent.
12
13
14
15
16
17
|
# File 'app/components/blacklight/document/thumbnail_component.rb', line 12
def initialize(presenter: nil, document: nil, counter:, image_options: {})
@presenter = presenter
@document = presenter&.document || document
@counter = counter
@image_options = { alt: '' }.merge(image_options)
end
|
Instance Method Details
#presenter ⇒ Object
31
32
33
|
# File 'app/components/blacklight/document/thumbnail_component.rb', line 31
def presenter
@presenter ||= helpers.document_presenter(@document)
end
|
#render? ⇒ Boolean
19
20
21
|
# File 'app/components/blacklight/document/thumbnail_component.rb', line 19
def render?
presenter.thumbnail.exists?
end
|
#use_thumbnail_tag_behavior? ⇒ Boolean
23
24
25
|
# File 'app/components/blacklight/document/thumbnail_component.rb', line 23
def use_thumbnail_tag_behavior?
!presenter.thumbnail.instance_of?(Blacklight::ThumbnailPresenter)
end
|
#warn_about_deprecated_behavior ⇒ Object
27
28
29
|
# File 'app/components/blacklight/document/thumbnail_component.rb', line 27
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
|