Browse Source

Issue #964: Allow relative paths in IIIF manifests.

pull/965/head
Alexander O'Neill 2 years ago
parent
commit
f370600a40
  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: iiif_server:
type: string type: string
label: 'IIIF Server Url' label: 'IIIF Server Url'
use_relative_paths:
type: boolean
label: 'Use relative paths in manifest.'
views.style.iiif_manifest: views.style.iiif_manifest:
type: views_style 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.'), '#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'), '#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); return parent::buildForm($form, $form_state);
} }
@ -99,6 +107,7 @@ class IslandoraIIIFConfigForm extends ConfigFormBase {
$this->config('islandora_iiif.settings') $this->config('islandora_iiif.settings')
->set('iiif_server', $form_state->getValue('iiif_server')) ->set('iiif_server', $form_state->getValue('iiif_server'))
->set('use_relative_paths', $form_state->getValue('use_relative_paths'))
->save(); ->save();
} }

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

@ -228,7 +228,13 @@ class IIIFManifest extends StylePluginBase {
// Create the IIIF URL for this file // Create the IIIF URL for this file
// Visiting $iiif_url will resolve to the info.json for the image. // 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(); $mime_type = $image->entity->getMimeType();
$iiif_url = rtrim($iiif_address, '/') . '/' . urlencode($file_url); $iiif_url = rtrim($iiif_address, '/') . '/' . urlencode($file_url);

Loading…
Cancel
Save