From c736f6d3ff426c5c6c23f04b0c2e39a1fe0e5841 Mon Sep 17 00:00:00 2001 From: buttle Date: Mon, 17 May 2021 22:23:01 +0200 Subject: [PATCH] fixes null attachment bug --- src/Site/BlockLayout/HeaderImage.php | 9 +-------- src/View/Helper/HeaderImageViewHelper.php | 6 ++++-- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/Site/BlockLayout/HeaderImage.php b/src/Site/BlockLayout/HeaderImage.php index d0a3ad4..2542a00 100644 --- a/src/Site/BlockLayout/HeaderImage.php +++ b/src/Site/BlockLayout/HeaderImage.php @@ -45,14 +45,7 @@ class HeaderImage extends AbstractBlockLayout $form = $this->formElementManager->get(HeaderImageBlockForm::class); $form->prepare(); - $html = ''; - $html .= $view->blockAttachmentsForm($block); - //$html .= '

'; - //$html .= $view->translate('Options'). '

'; - //$html .= '
'; - //$html .= $view->formCollection($form); - //$html .= '
'; - return $html; + return $view->blockAttachmentsForm($block); } public function render(PhpRenderer $view, SitePageBlockRepresentation $block) diff --git a/src/View/Helper/HeaderImageViewHelper.php b/src/View/Helper/HeaderImageViewHelper.php index 6666180..cea6509 100644 --- a/src/View/Helper/HeaderImageViewHelper.php +++ b/src/View/Helper/HeaderImageViewHelper.php @@ -25,8 +25,10 @@ class HeaderImageViewHelper extends AbstractHelper foreach ($page->blocks() as $block) { if ($block->layout() === 'headerImage') { $attachments = $block->attachments(); - $media = $attachments[0]->item()->media()[0]; - return $media->primaryMedia()->thumbnailUrl('large'); + if ($$attachments) { + $media = $attachments[0]->item()->media()[0]; + return $media->primaryMedia()->thumbnailUrl('large'); + } } } $site = $this->currentSite();