adds getSiteImage function

This commit is contained in:
buttle 2021-05-17 20:01:55 +02:00
parent ed7118bb96
commit 411b86a3fd
1 changed files with 17 additions and 0 deletions

View File

@ -95,6 +95,23 @@ class ArchiveSiteMetaViewHelper extends AbstractHelper
return null; 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 * @return \Omeka\Api\Representation\SiteRepresentation
*/ */