removes getPageImage. now handled by HeaderImage module

This commit is contained in:
buttle 2021-05-17 22:03:27 +02:00
parent 411b86a3fd
commit 80662a6c9e
1 changed files with 23 additions and 26 deletions

View File

@ -3,12 +3,6 @@ namespace ArchiveSiteMeta\View\Helper;
use Laminas\View\Helper\AbstractHelper; use Laminas\View\Helper\AbstractHelper;
//class ArchiveSiteMeta implements FactoryInterface
//{
#use ArchiveSiteMeta\Service\Form\ConfigFormFactory;
/** /**
* View helper to get metadata for all pages of the specified type. * View helper to get metadata for all pages of the specified type.
*/ */
@ -74,36 +68,19 @@ class ArchiveSiteMetaViewHelper extends AbstractHelper
{ {
return []; return [];
} }
/** /**
* Get the page's meta image url. * Get the site's meta image url.
* *
* @param SitePageRepresentation * @param SiteRepresentation
* @return string media url * @return string media url
*/ */
public function getPageImage($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;
}
public function getSiteImage($site) public function getSiteImage($site)
{ {
foreach ($site->pages() as $page) { foreach ($site->pages() as $page) {
foreach ($page->blocks() as $block) { foreach ($page->blocks() as $block) {
if ($block->layout() === 'archiveSiteMeta') { if ($block->layout() === 'archiveSiteMeta') {
$attachments = $block->attachments(); $attachments = $block->attachments();
//if (!$attachments) {
// return null;
//}
$media = $attachments[0]->item()->media()[0]; $media = $attachments[0]->item()->media()[0];
return $media->primaryMedia()->thumbnailUrl('large'); return $media->primaryMedia()->thumbnailUrl('large');
} }
@ -112,6 +89,26 @@ class ArchiveSiteMetaViewHelper extends AbstractHelper
return null; return null;
} }
/**
* Get the page's meta image url.
*
* @param SitePageRepresentation
* @return string media url
*/
/*
public function getPageImage($page)
{
foreach ($page->blocks() as $block) {
if ($block->layout() === 'archiveSiteMeta') {
$attachments = $block->attachments();
$media = $attachments[0]->item()->media()[0];
return $media->primaryMedia()->thumbnailUrl('large');
}
}
return $this->getSiteImage($page->site());
}
*/
/** /**
* @return \Omeka\Api\Representation\SiteRepresentation * @return \Omeka\Api\Representation\SiteRepresentation
*/ */