From 9f7ea9ffe80805d1be2873f334d32f0fa982566f Mon Sep 17 00:00:00 2001 From: rmens Date: Mon, 21 Oct 2024 08:43:05 +0200 Subject: [PATCH] Check if image exists --- lib/teksttv.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/teksttv.php b/lib/teksttv.php index db14f9d..0f922f2 100644 --- a/lib/teksttv.php +++ b/lib/teksttv.php @@ -170,11 +170,16 @@ private function get_primary_category_image($post_id) private function get_image_slide($block) { - return [ - 'type' => 'image', - 'duration' => \intval($block['seconden']) * 1000, - 'url' => $block['afbeelding']['url'], - ]; + // Check if the image exists + if (!empty($block['afbeelding']) && !empty($block['afbeelding']['url'])) { + return [ + 'type' => 'image', + 'duration' => \intval($block['seconden']) * 1000, + 'url' => $block['afbeelding']['url'], + ]; + } + // If no image exists, return null or an empty array, depending on your needs + return null; } private function get_ad_campaigns()