Module: Hyrax::DisplaysImage

Extended by:
ActiveSupport::Concern
Included in:
FileSetPresenter
Defined in:
app/presenters/hyrax/displays_image.rb

Overview

This gets mixed into FileSetPresenter in order to create a canvas on a IIIF manifest

Instance Method Summary collapse

Instance Method Details

#display_imageIIIFManifest::DisplayImage

Creates a display image only where FileSet is an image.

Returns:

  • (IIIFManifest::DisplayImage)

    the display image required by the manifest builder.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'app/presenters/hyrax/displays_image.rb', line 12

def display_image
  return nil unless solr_document.image? && current_ability.can?(:read, solr_document)

  latest_file_id = lookup_original_file_id

  return nil unless latest_file_id

  url = Hyrax.config.iiif_image_url_builder.call(
    latest_file_id,
    request.base_url,
    Hyrax.config.iiif_image_size_default
  )

  # @see https://github.com/samvera-labs/iiif_manifest
  IIIFManifest::DisplayImage.new(url,
                                 format: image_format([]),
                                 width: width,
                                 height: height,
                                 iiif_endpoint: iiif_endpoint(latest_file_id))
end