Browse Source

speed up iiif manifest generation

IIIFManifest_speedup
ppound 7 months ago
parent
commit
3471fd3a4b
  1. 16
      modules/islandora_iiif/src/Plugin/views/style/IIIFManifest.php

16
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();

Loading…
Cancel
Save