Browse Source

Add Structured OCR field to IIIF Manifest view.

pull/897/head
Alexander O'Neill 2 years ago
parent
commit
bd17a381ea
  1. 10
      modules/islandora_iiif/src/Plugin/views/style/IIIFManifest.php
  2. 5
      src/Plugin/Action/AbstractGenerateDerivativeMediaFile.php

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

@ -313,6 +313,7 @@ class IIIFManifest extends StylePluginBase {
$options = parent::defineOptions(); $options = parent::defineOptions();
$options['iiif_tile_field'] = ['default' => '']; $options['iiif_tile_field'] = ['default' => ''];
$options['iiif_ocr_file_field'] = ['default' => ''];
return $options; return $options;
} }
@ -368,6 +369,15 @@ class IIIFManifest extends StylePluginBase {
// otherwise could lock up the form when setting up a View. // otherwise could lock up the form when setting up a View.
'#required' => count($field_options) > 0, '#required' => count($field_options) > 0,
]; ];
$form['iiif_ocr_file_field'] = [
'#title' => $this->t('Structured OCR data file field'),
'#type' => 'checkboxes',
'#default_value' => $this->options['iiif_ocr_file_field'],
'#description' => $this->t('The source of structured OCR text for each entity.'),
'#options' => $field_options,
'#required' => FALSE,
];
} }
/** /**

5
src/Plugin/Action/AbstractGenerateDerivativeMediaFile.php

@ -5,7 +5,6 @@ namespace Drupal\islandora\Plugin\Action;
use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url; use Drupal\Core\Url;
/** /**
* Emits a Node for generating derivatives event. * Emits a Node for generating derivatives event.
* *
@ -39,8 +38,8 @@ class AbstractGenerateDerivativeMediaFile extends AbstractGenerateDerivativeBase
*/ */
protected function generateData(EntityInterface $entity) { protected function generateData(EntityInterface $entity) {
$data = parent::generateData($entity); $data = parent::generateData($entity);
if (get_class($entity) != 'Drupal\media\Entity\Media') { if (get_class($entity) != 'Drupal\media\Entity\Media') {
throw new \RuntimeException("Entity {$entity->getEntityTypeId()} {$entity->id()} is not a media", 500); throw new \RuntimeException("Entity {$entity->getEntityTypeId()} {$entity->id()} is not a media", 500);
} }
$source_file = $this->mediaSource->getSourceFile($entity); $source_file = $this->mediaSource->getSourceFile($entity);
if (!$source_file) { if (!$source_file) {

Loading…
Cancel
Save