diff --git a/src/Plugin/ContextReaction/JsonldSelfReferenceReaction.php b/src/Plugin/ContextReaction/JsonldSelfReferenceReaction.php index ed6aac95e..97454ca43 100644 --- a/src/Plugin/ContextReaction/JsonldSelfReferenceReaction.php +++ b/src/Plugin/ContextReaction/JsonldSelfReferenceReaction.php @@ -88,10 +88,11 @@ public function execute(EntityInterface $entity = NULL, array &$normalized = NUL if (isset($normalized['@graph']) && is_array($normalized['@graph'])) { foreach ($normalized['@graph'] as &$graph) { if (isset($graph['@id']) && $graph['@id'] == $url) { - // Swap media and file urls. + // If a file URL is available, swap it in as the ID. if ($entity instanceof MediaInterface) { - $file = $this->mediaSource->getSourceFile($entity); - $graph['@id'] = $this->utils->getDownloadUrl($file); + if ($file = $this->mediaSource->getSourceFile($entity)) { + $graph['@id'] = $this->utils->getDownloadUrl($file); + } } if (isset($graph[$self_ref_predicate])) { if (!is_array($graph[$self_ref_predicate])) {