From 2f50c53e24ef515b82bc1129508be1217eff4949 Mon Sep 17 00:00:00 2001
From: Alexander O'Neill <aloneill@gmail.com>
Date: Wed, 7 Sep 2022 16:16:31 +0000
Subject: [PATCH] Add empty check when adding hOCR to IIIF manifest.

---
 .../islandora_iiif/src/Plugin/views/style/IIIFManifest.php  | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/modules/islandora_iiif/src/Plugin/views/style/IIIFManifest.php b/modules/islandora_iiif/src/Plugin/views/style/IIIFManifest.php
index ad5ea178..561b216d 100644
--- a/modules/islandora_iiif/src/Plugin/views/style/IIIFManifest.php
+++ b/modules/islandora_iiif/src/Plugin/views/style/IIIFManifest.php
@@ -191,13 +191,13 @@ class IIIFManifest extends StylePluginBase {
     $canvases = [];
     foreach (array_filter(array_values($this->options['iiif_tile_field'])) as $iiif_tile_field) {
       $viewsField = $this->view->field[$iiif_tile_field];
-      $iiif_ocr_file_field = array_filter(array_values($this->options['iiif_ocr_file_field']));
+      $iiif_ocr_file_field = !empty($this->options['iiif_ocr_file_field']) ? array_filter(array_values($this->options['iiif_ocr_file_field'])): array();
       $ocrField = count($iiif_ocr_file_field) > 0 ? $this->view->field[$iiif_ocr_file_field[0]] : NULL;
       $entity = $viewsField->getEntity($row);
 
       if (isset($entity->{$viewsField->definition['field_name']})) {
 
-        /** @var \Drupal\Core\Field\FieldItemListInterface $images */
+        /** @var \Drupal\Core\Field\FieldItemListInterface $images */ 
         $images = $entity->{$viewsField->definition['field_name']}; 
         foreach ($images as $image) {
           if (!$image->entity->access('view')) {
@@ -209,7 +209,7 @@ class IIIFManifest extends StylePluginBase {
 
           // Create the IIIF URL for this file
           // Visiting $iiif_url will resolve to the info.json for the image.
-          $ocr = isset($ocrs[$i]) ? $ocrs[$i] : NULL;
+          $ocr = isset($ocrs[$i]) ? $ocrs[$i] : FALSE;
           $file_url = $image->entity->createFileUrl(FALSE);
           $mime_type = $image->entity->getMimeType();
           $iiif_url = rtrim($iiif_address, '/') . '/' . urlencode($file_url);