Skip to content

Commit

Permalink
959-iiif-width-height-caching Add option to skip retrieveing TIFF and…
Browse files Browse the repository at this point in the history
… JP2 dimensions from IIIF server.
  • Loading branch information
alxp committed Feb 7, 2024
1 parent 6a1c033 commit fa7f449
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ views.style.iiif_manifest:
structured_text_term:
type: string
label: "Structured text term"
getdimensions_from_sewrver:

This comment has been minimized.

Copy link
@rosiel

rosiel Feb 7, 2024

Member

typo in server.

This comment has been minimized.

Copy link
@bondjimbond

bondjimbond Feb 8, 2024

Also missing an underscore (get_dimensions rather than getdimensions is used on lines 391 and 572).

type: boolean
label: "Retrieve image dimensions from IIIF server"
search_endpoint:
type: string
label: "Search endpoint path"
18 changes: 15 additions & 3 deletions modules/islandora_iiif/src/Plugin/views/style/IIIFManifest.php
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,9 @@ protected function getTileSourceFromRow(ResultRow $row, $iiif_address, $iiif_bas
$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
Expand Down Expand Up @@ -385,9 +388,11 @@ protected function getCanvasDimensions(string $iiif_url, FieldItemInterface $ima

// As a last resort, get it from the IIIF server.
// This can be very slow and will fail if there are too many pages.
$dimensions = $this->iiifInfo->getImageDimensions($image->entity);
if ($dimensions !== FALSE) {
return $dimensions;
if ($this->options['get_dimensions_from_server']) {
$dimensions = $this->iiifInfo->getImageDimensions($image->entity);
if ($dimensions !== FALSE) {
return $dimensions;
}
}

return [0, 0];
Expand Down Expand Up @@ -560,6 +565,13 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) {
'#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."),
Expand Down

0 comments on commit fa7f449

Please sign in to comment.