From bd327d98b549ec06267cf39c8407dded97e3818f Mon Sep 17 00:00:00 2001 From: Alexander O'Neill Date: Thu, 15 Feb 2024 09:06:04 -0400 Subject: [PATCH] 959-iiif-width-height-caching Add IIIF service function to get downlaod link with given dimensions. --- modules/islandora_iiif/src/IiifInfo.php | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/modules/islandora_iiif/src/IiifInfo.php b/modules/islandora_iiif/src/IiifInfo.php index 66d83fe3..c39a3cee 100644 --- a/modules/islandora_iiif/src/IiifInfo.php +++ b/modules/islandora_iiif/src/IiifInfo.php @@ -98,7 +98,7 @@ class IiifInfo { } /** - * Retrieve an image's dimensions via the IIIF server. + * Retrieve an image's original dimensions via the IIIF server. * * @param \Drupal\File\FileInterface $file * The image file. @@ -127,4 +127,27 @@ class IiifInfo { return FALSE; } +/** + * The IIIF base URL for an image. + * + * Visiting this URL will resolve to the full image resized to the maximum dimensions given. + * + * @see https://iiif.io/api/image/2.1/ + * + * @param Drupal\file\FileInterface $image + * The image entity. + * @param int width + * The maximum width of the image to be returned. 0 for no constraint. + * @param int $height + * The maxim um height of the image to be returned. 0 for no contraint. + * + * @return string + * The IIIF URl to retrieve the full image with the given max dimensions. + */ + public function getImageWithMaxDimensions($image, $width = 0, $height = 0) { + $base_url = $this->baseUrl($image); + return $base_url . "/full/!$width,$height/0/default.jpg"; + + } + }