From: Ben Sherratt Date: Sun, 19 Nov 2023 16:33:09 +0000 (+0000) Subject: Don't break when there's no hero image X-Git-Url: https://git.bts.cx/cx.git/commitdiff_plain/c678faf602beee2b667adba59916f00e211b3fd3?hp=04d8d3de247226f9530964084bdf16e55c9f2742 Don't break when there's no hero image --- diff --git a/cx/lib/posts.php b/cx/lib/posts.php index 2c2dc82..0a2ac4d 100644 --- a/cx/lib/posts.php +++ b/cx/lib/posts.php @@ -15,8 +15,8 @@ class PostMetadata { public $hero_image_alt; public function __construct($dict) { - $this->hero_image = $dict['post_hero_image']; - $this->hero_image_alt = $dict['post_hero_image_alt']; + $this->hero_image = isset($dict['post_hero_image']) ? $dict['post_hero_image'] : null; + $this->hero_image_alt = isset($dict['post_hero_image_alt']) ? $dict['post_hero_image_alt'] : null; } } diff --git a/cx/templates/public/base.php b/cx/templates/public/base.php index d031247..f5e9670 100644 --- a/cx/templates/public/base.php +++ b/cx/templates/public/base.php @@ -19,10 +19,17 @@ + + hero_image)): ?> + + + + hero_image_alt)): ?> +