From 411b86a3fda16f8e43eec596bafb26f4142d43bf Mon Sep 17 00:00:00 2001 From: buttle Date: Mon, 17 May 2021 20:01:55 +0200 Subject: [PATCH] adds getSiteImage function --- src/View/Helper/ArchiveSiteMetaViewHelper.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/View/Helper/ArchiveSiteMetaViewHelper.php b/src/View/Helper/ArchiveSiteMetaViewHelper.php index 1643a65..c7845f8 100644 --- a/src/View/Helper/ArchiveSiteMetaViewHelper.php +++ b/src/View/Helper/ArchiveSiteMetaViewHelper.php @@ -95,6 +95,23 @@ class ArchiveSiteMetaViewHelper extends AbstractHelper return null; } + public function getSiteImage($site) + { + foreach ($site->pages() as $page) { + foreach ($page->blocks() as $block) { + if ($block->layout() === 'archiveSiteMeta') { + $attachments = $block->attachments(); + //if (!$attachments) { + // return null; + //} + $media = $attachments[0]->item()->media()[0]; + return $media->primaryMedia()->thumbnailUrl('large'); + } + } + } + return null; + } + /** * @return \Omeka\Api\Representation\SiteRepresentation */