Browse Source

959-iiif-width-height-caching Add option to skip retrieveing TIFF and JP2 dimensions from IIIF server.

959-iiif-width-height-caching
Alexander O'Neill 8 months ago
parent
commit
fa7f4494b5
  1. 3
      modules/islandora_iiif/config/schema/islandora_iiif.schema.yml
  2. 12
      modules/islandora_iiif/src/Plugin/views/style/IIIFManifest.php

3
modules/islandora_iiif/config/schema/islandora_iiif.schema.yml

@ -25,6 +25,9 @@ views.style.iiif_manifest:
structured_text_term:
type: string
label: "Structured text term"
getdimensions_from_sewrver:
type: boolean
label: "Retrieve image dimensions from IIIF server"
search_endpoint:
type: string
label: "Search endpoint path"

12
modules/islandora_iiif/src/Plugin/views/style/IIIFManifest.php

@ -272,6 +272,9 @@ $this->addSearchEndpoint($json, $url_components);
$annotation_id = $iiif_base_id . '/annotation/' . $entity->id();
[$width, $height] = $this->getCanvasDimensions($iiif_url, $image, $mime_type);
if ($width == 0) {
continue;
}
$tmp_canvas = [
// @see https://iiif.io/api/presentation/2.1/#canvas
@ -385,10 +388,12 @@ $this->addSearchEndpoint($json, $url_components);
// As a last resort, get it from the IIIF server.
// This can be very slow and will fail if there are too many pages.
if ($this->options['get_dimensions_from_server']) {
$dimensions = $this->iiifInfo->getImageDimensions($image->entity);
if ($dimensions !== FALSE) {
return $dimensions;
}
}
return [0, 0];
}
@ -560,6 +565,13 @@ $this->addSearchEndpoint($json, $url_components);
'#description' => $this->t('Term indicating the media that holds structured text, such as hOCR, for the given object. Use this if the text is on a separate media from the tile source.'),
];
$form['get_dimensions_from_server'] = [
'#type' => 'checkbox',
'#title' => $this->t("Retrieve image dimensions from IIIF server"),
'#description' => $this->t("For TIFFs and JP2s, if the media doesn't have width and height values populated, as a last resort, retrieve the info from the IIIF server. This can be very slow and is not recommended."),
'#default_value' => $this->options['get_dimensions_from_server'],
];
$form['search_endpoint'] = [
'#type' => 'textfield',
'#title' => $this->t("Search endpoint path."),

Loading…
Cancel
Save