Skip to content

Commit

Permalink
issue #959: Cache TIFF witdh and height into fields on File media if …
Browse files Browse the repository at this point in the history
…they exist.
  • Loading branch information
alxp committed Oct 6, 2023
1 parent f7a7782 commit 74eb9ea
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion modules/islandora_iiif/src/Plugin/views/style/IIIFManifest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 74eb9ea

Please sign in to comment.