From 74eb9ea23ed75770dc2f05a3a89742eabe1bc78f Mon Sep 17 00:00:00 2001 From: Alexander O'Neill Date: Fri, 6 Oct 2023 16:44:29 -0300 Subject: [PATCH] issue #959: Cache TIFF witdh and height into fields on File media if they exist. --- .../src/Plugin/views/style/IIIFManifest.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/modules/islandora_iiif/src/Plugin/views/style/IIIFManifest.php b/modules/islandora_iiif/src/Plugin/views/style/IIIFManifest.php index 804153abf..4a9b47a61 100644 --- a/modules/islandora_iiif/src/Plugin/views/style/IIIFManifest.php +++ b/modules/islandora_iiif/src/Plugin/views/style/IIIFManifest.php @@ -250,7 +250,19 @@ protected function getTileSourceFromRow(ResultRow $row, $iiif_address, $iiif_bas $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); + if ($entity->hasField('field_height') && !$entity->get('field_height')->isEmpty() && $entity->get('field_height')->value > 0 && $entity->hasField('field_width') && !$entity->get('field_width')->isEmpty() && $entity->get('field_width')->value > 0) { + $width = $entity->get('field_width')->value; + $height = $entity->get('field_height')->value; + } + else { + [$width, $height] = $this->getCanvasDimensions($iiif_url, $image, $mime_type); + } + + if ($entity->hasField('field_height') && $entity->get('field_height')->isEmpty() && $entity->hasField('field_width') && $entity->get('field_width')->isEmpty()) { + $entity->set('field_width', $width); + $entity->set('field_height', $height); + $entity->save(); + } $tmp_canvas = [ // @see https://iiif.io/api/presentation/2.1/#canvas