Browse Source

Issue #964: Allow relative paths in IIIF manifests. (#965)

* Issue #964: Allow relative paths in IIIF manifests.

* Address PHPCS error.

* Fix missing use statement.
pull/970/head
Alexander O'Neill 1 year ago committed by GitHub
parent
commit
11afd42c8a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      modules/islandora_iiif/config/schema/islandora_iiif.schema.yml
  2. 9
      modules/islandora_iiif/src/Form/IslandoraIIIFConfigForm.php
  3. 8
      modules/islandora_iiif/src/Plugin/views/style/IIIFManifest.php

3
modules/islandora_iiif/config/schema/islandora_iiif.schema.yml

@ -5,6 +5,9 @@ islandora_iiif.settings:
iiif_server:
type: string
label: 'IIIF Server Url'
use_relative_paths:
type: boolean
label: 'Use relative paths in manifest.'
views.style.iiif_manifest:
type: views_style

9
modules/islandora_iiif/src/Form/IslandoraIIIFConfigForm.php

@ -73,6 +73,14 @@ class IslandoraIIIFConfigForm extends ConfigFormBase {
'#description' => $this->t('Please enter the image server location without trailing slash. e.g. http://www.example.org/iiif/2.'),
'#default_value' => $config->get('iiif_server'),
];
$form['use_relative_paths'] = [
'#type' => 'checkbox',
'#title' => $this->t("Use relative file paths in manifest."),
'#description' => $this->t("Check this if your IIIF Server is configured to access files locally. If unchecked, the absolute URL will be given and the IIIF server will make requests to this site to retrieve images."),
'#default_value' => $config->get('use_relative_paths'),
];
return parent::buildForm($form, $form_state);
}
@ -99,6 +107,7 @@ class IslandoraIIIFConfigForm extends ConfigFormBase {
$this->config('islandora_iiif.settings')
->set('iiif_server', $form_state->getValue('iiif_server'))
->set('use_relative_paths', $form_state->getValue('use_relative_paths'))
->save();
}

8
modules/islandora_iiif/src/Plugin/views/style/IIIFManifest.php

@ -229,7 +229,13 @@ class IIIFManifest extends StylePluginBase {
// Create the IIIF URL for this file
// Visiting $iiif_url will resolve to the info.json for the image.
$file_url = $image->entity->createFileUrl(FALSE);
if ($this->iiifConfig->get('use_relative_paths')) {
$file_url = ltrim($image->entity->createFileUrl(TRUE), '/');
}
else {
$file_url = $image->entity->createFileUrl(FALSE);
}
$mime_type = $image->entity->getMimeType();
$iiif_url = rtrim($iiif_address, '/') . '/' . urlencode($file_url);

Loading…
Cancel
Save