From 3471fd3a4b10c75e99293f1de7157f52d5340733 Mon Sep 17 00:00:00 2001 From: ppound Date: Mon, 27 May 2024 13:42:48 -0300 Subject: [PATCH] speed up iiif manifest generation --- .../src/Plugin/views/style/IIIFManifest.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/modules/islandora_iiif/src/Plugin/views/style/IIIFManifest.php b/modules/islandora_iiif/src/Plugin/views/style/IIIFManifest.php index f0aca47d..4d2fd3a9 100644 --- a/modules/islandora_iiif/src/Plugin/views/style/IIIFManifest.php +++ b/modules/islandora_iiif/src/Plugin/views/style/IIIFManifest.php @@ -296,7 +296,7 @@ class IIIFManifest extends StylePluginBase { $canvas_id = $iiif_base_id . '/canvas/' . $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, $entity, $mime_type); $tmp_canvas = [ // @see https://iiif.io/api/presentation/2.1/#canvas @@ -365,12 +365,14 @@ class IIIFManifest extends StylePluginBase { * @return [string] * The width and height of the image. */ - protected function getCanvasDimensions(string $iiif_url, FieldItemInterface $image, string $mime_type) { - - if (isset($image->width) && is_numeric($image->width) - && isset($image->height) && is_numeric($image->height)) { - return [intval($image->width), intval($image->height)]; - } + protected function getCanvasDimensions(string $iiif_url, $image, string $mime_type) { + + $height = $image->get('field_height')->value; + $width = $image->get('field_width')->value; + if (isset($width) && is_numeric($width) + && isset($height) && is_numeric($height)) { + return [intval($width), intval($height)]; + } try { $info_json = $this->httpClient->get($iiif_url)->getBody();