diff --git a/modules/islandora_iiif/config/schema/islandora_iiif.schema.yml b/modules/islandora_iiif/config/schema/islandora_iiif.schema.yml index fc62c5c4c..f9e870efa 100644 --- a/modules/islandora_iiif/config/schema/islandora_iiif.schema.yml +++ b/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 diff --git a/modules/islandora_iiif/src/Form/IslandoraIIIFConfigForm.php b/modules/islandora_iiif/src/Form/IslandoraIIIFConfigForm.php index dc750a5a9..f09a01430 100644 --- a/modules/islandora_iiif/src/Form/IslandoraIIIFConfigForm.php +++ b/modules/islandora_iiif/src/Form/IslandoraIIIFConfigForm.php @@ -73,6 +73,14 @@ public function buildForm(array $form, FormStateInterface $form_state) { '#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 @@ public function submitForm(array &$form, FormStateInterface $form_state) { $this->config('islandora_iiif.settings') ->set('iiif_server', $form_state->getValue('iiif_server')) + ->set('use_relative_paths', $form_state->getValue('use_relative_paths')) ->save(); } diff --git a/modules/islandora_iiif/src/Plugin/views/style/IIIFManifest.php b/modules/islandora_iiif/src/Plugin/views/style/IIIFManifest.php index b5175ed9d..9d31d760d 100644 --- a/modules/islandora_iiif/src/Plugin/views/style/IIIFManifest.php +++ b/modules/islandora_iiif/src/Plugin/views/style/IIIFManifest.php @@ -229,7 +229,13 @@ protected function getTileSourceFromRow(ResultRow $row, $iiif_address, $iiif_bas // 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);