diff --git a/src/Plugin/OaiMetadataMap/DgiStandard.php b/src/Plugin/OaiMetadataMap/DgiStandard.php index 3c43fc0..046710d 100644 --- a/src/Plugin/OaiMetadataMap/DgiStandard.php +++ b/src/Plugin/OaiMetadataMap/DgiStandard.php @@ -4,9 +4,11 @@ use Drupal\Core\Entity\ContentEntityInterface; use Drupal\Core\Entity\EntityTypeManagerInterface; -use Drupal\Core\Field\FieldItemListInterface; use Drupal\Core\Field\EntityReferenceFieldItemListInterface; +use Drupal\Core\Field\FieldItemListInterface; +use Drupal\Core\GeneratedUrl; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; +use Drupal\image\ImageStyleInterface; use Drupal\dgi_image_discovery\ImageDiscovery; use Drupal\entity_reference_revisions\EntityReferenceRevisionsFieldItemList; use Drupal\islandora\IslandoraUtils; @@ -137,6 +139,9 @@ class DgiStandard extends OaiMetadataMapBase implements ContainerFactoryPluginIn 'relators:spk' => 'dcterms:contributor', 'relators:spn' => 'dcterms:contributor', 'realtors:vdg' => 'dcterms:contributor', + 'relators:art' => 'dcterms:creator', + 'relators:ill' => 'dcterms:contributor', + 'relators:trl' => 'dcterms:contributor', ]; /** @@ -160,6 +165,13 @@ class DgiStandard extends OaiMetadataMapBase implements ContainerFactoryPluginIn */ protected ImageDiscovery $imageDiscovery; + /** + * The URL generator. + * + * @var \Drupal\dgi_image_discovery\UrlGeneratorPluginBase + */ + protected $urlGenerator; + /** * {@inheritdoc} */ @@ -170,6 +182,7 @@ public static function create(ContainerInterface $container, array $configuratio $plugin->entityTypeManager = $container->get('entity_type.manager'); $plugin->utils = $container->get('islandora.utils'); $plugin->imageDiscovery = $container->get('dgi_image_discovery.service'); + $plugin->urlGenerator = $container->get('plugin.manager.dgi_image_discovery.url_generator')->createInstance('deferred'); return $plugin; } @@ -386,14 +399,22 @@ protected function addPersistentUrl(ContentEntityInterface $entity, $dest, $alia * The destination index for the thumbnail. */ public function addThumbnail(ContentEntityInterface $entity, $dest) { - $event = $this->imageDiscovery->getImage($entity); + $style_id = 'solr_grid_thumbnail'; + + // Load the image style. + $style = $this->entityTypeManager->getStorage('image_style')->load($style_id); - if ($event->hasMedia()) { - $media = $event->getMedia(); + if ($style instanceof ImageStyleInterface) { + // Generate the URL using the Deferred plugin. + $generated_url = $this->urlGenerator->generate($entity, $style); - $fid = $media->getSource()->getSourceFieldValue($media); - $file = $this->entityTypeManager->getStorage('file')->load($fid); - $this->elements[$dest][] = $file->createFileUrl(FALSE); + // Add the resolved image URL to the elements array. + if ($generated_url instanceof GeneratedUrl) { + $url = $generated_url->getGeneratedUrl(); + if (!empty($url)) { + $this->elements[$dest][] = $url; + } + } } }