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
# File 'app/presenters/hyrax/displays_image.rb', line 12

def display_image
  return nil unless ::FileSet.exists?(id) && solr_document.image? && current_ability.can?(:read, id)
  # @todo this is slow, find a better way (perhaps index iiif url):
  original_file = ::FileSet.find(id).original_file

  url = Hyrax.config.iiif_image_url_builder.call(
    original_file.id,
    request.base_url,
    Hyrax.config.iiif_image_size_default
  )
  # @see https://github.com/samvera-labs/iiif_manifest
  IIIFManifest::DisplayImage.new(url,
                                 width: 640,
                                 height: 480,
                                 iiif_endpoint: iiif_endpoint(original_file.id))
end