Class: Blacklight::ThumbnailPresenter
- Inherits:
-
Object
- Object
- Blacklight::ThumbnailPresenter
- Defined in:
- app/presenters/blacklight/thumbnail_presenter.rb
Instance Attribute Summary collapse
-
#document ⇒ Object
readonly
Returns the value of attribute document.
-
#view_config ⇒ Object
readonly
Returns the value of attribute view_config.
-
#view_context ⇒ Object
readonly
Returns the value of attribute view_context.
Instance Method Summary collapse
-
#exists? ⇒ Boolean
Does the document have a thumbnail to render?.
-
#initialize(document, view_context, view_config) ⇒ ThumbnailPresenter
constructor
A new instance of ThumbnailPresenter.
- #render(image_options = {}) ⇒ Object
-
#thumbnail_tag(image_options = {}, url_options = {}) ⇒ String
Render the thumbnail, if available, for a document and link it to the document record.
Constructor Details
#initialize(document, view_context, view_config) ⇒ ThumbnailPresenter
Returns a new instance of ThumbnailPresenter.
11 12 13 14 15 |
# File 'app/presenters/blacklight/thumbnail_presenter.rb', line 11 def initialize(document, view_context, view_config) @document = document @view_context = view_context @view_config = view_config end |
Instance Attribute Details
#document ⇒ Object (readonly)
Returns the value of attribute document.
5 6 7 |
# File 'app/presenters/blacklight/thumbnail_presenter.rb', line 5 def document @document end |
#view_config ⇒ Object (readonly)
Returns the value of attribute view_config.
5 6 7 |
# File 'app/presenters/blacklight/thumbnail_presenter.rb', line 5 def view_config @view_config end |
#view_context ⇒ Object (readonly)
Returns the value of attribute view_context.
5 6 7 |
# File 'app/presenters/blacklight/thumbnail_presenter.rb', line 5 def view_context @view_context end |
Instance Method Details
#exists? ⇒ Boolean
Does the document have a thumbnail to render?
25 26 27 28 29 |
# File 'app/presenters/blacklight/thumbnail_presenter.rb', line 25 def exists? thumbnail_method.present? || (thumbnail_field && thumbnail_value_from_document.present?) || default_thumbnail.present? end |
#render(image_options = {}) ⇒ Object
17 18 19 |
# File 'app/presenters/blacklight/thumbnail_presenter.rb', line 17 def render( = {}) thumbnail_value() end |
#thumbnail_tag(image_options = {}, url_options = {}) ⇒ String
Render the thumbnail, if available, for a document and link it to the document record.
38 39 40 41 42 43 |
# File 'app/presenters/blacklight/thumbnail_presenter.rb', line 38 def thumbnail_tag = {}, = {} value = thumbnail_value() return value if value.nil? || [:suppress_link] view_context.link_to_document document, value, end |