Browse Source

959-iiif-width-height-caching Add IIIF service function to get downlaod link with given dimensions.

959-iiif-width-height-caching
Alexander O'Neill 9 months ago
parent
commit
bd327d98b5
  1. 25
      modules/islandora_iiif/src/IiifInfo.php

25
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 * @param \Drupal\File\FileInterface $file
* The image file. * The image file.
@ -127,4 +127,27 @@ class IiifInfo {
return FALSE; 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";
}
} }

Loading…
Cancel
Save