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. 18
      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: structured_text_term:
type: string type: string
label: "Structured text term" label: "Structured text term"
getdimensions_from_sewrver:
type: boolean
label: "Retrieve image dimensions from IIIF server"
search_endpoint: search_endpoint:
type: string type: string
label: "Search endpoint path" label: "Search endpoint path"

18
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(); $annotation_id = $iiif_base_id . '/annotation/' . $entity->id();
[$width, $height] = $this->getCanvasDimensions($iiif_url, $image, $mime_type); [$width, $height] = $this->getCanvasDimensions($iiif_url, $image, $mime_type);
if ($width == 0) {
continue;
}
$tmp_canvas = [ $tmp_canvas = [
// @see https://iiif.io/api/presentation/2.1/#canvas // @see https://iiif.io/api/presentation/2.1/#canvas
@ -385,9 +388,11 @@ $this->addSearchEndpoint($json, $url_components);
// As a last resort, get it from the IIIF server. // As a last resort, get it from the IIIF server.
// This can be very slow and will fail if there are too many pages. // This can be very slow and will fail if there are too many pages.
$dimensions = $this->iiifInfo->getImageDimensions($image->entity); if ($this->options['get_dimensions_from_server']) {
if ($dimensions !== FALSE) { $dimensions = $this->iiifInfo->getImageDimensions($image->entity);
return $dimensions; if ($dimensions !== FALSE) {
return $dimensions;
}
} }
return [0, 0]; 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.'), '#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'] = [ $form['search_endpoint'] = [
'#type' => 'textfield', '#type' => 'textfield',
'#title' => $this->t("Search endpoint path."), '#title' => $this->t("Search endpoint path."),

Loading…
Cancel
Save