fixes null attachment bug

This commit is contained in:
buttle 2021-05-17 22:23:01 +02:00
parent e999f52e86
commit c736f6d3ff
2 changed files with 5 additions and 10 deletions

View File

@ -45,14 +45,7 @@ class HeaderImage extends AbstractBlockLayout
$form = $this->formElementManager->get(HeaderImageBlockForm::class);
$form->prepare();
$html = '';
$html .= $view->blockAttachmentsForm($block);
//$html .= '<a href="#" class="collapse" aria-label="collapse"><h4>';
//$html .= $view->translate('Options'). '</h4></a>';
//$html .= '<div class="collapsible" style="padding-top:6px;">';
//$html .= $view->formCollection($form);
//$html .= '</div>';
return $html;
return $view->blockAttachmentsForm($block);
}
public function render(PhpRenderer $view, SitePageBlockRepresentation $block)

View File

@ -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();