From ce23850edddef0de9c8144e521a50a8fb83c180d Mon Sep 17 00:00:00 2001 From: danpros Date: Thu, 22 Feb 2024 19:43:53 +0700 Subject: [PATCH] Update functions.php --- system/includes/functions.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/system/includes/functions.php b/system/includes/functions.php index 83812ff..d5e928d 100644 --- a/system/includes/functions.php +++ b/system/includes/functions.php @@ -2907,7 +2907,7 @@ function generate_rss($posts, $data = null) } if ($posts) { foreach ($posts as $p) { - + $img = get_image($p->body); if (!empty($rssLength)) { if (strlen(strip_tags($p->body)) < config('rss.char')) { $string = preg_replace('/\s\s+/', ' ', strip_tags($p->body)); @@ -2931,10 +2931,13 @@ function generate_rss($posts, $data = null) ->description($body) ->url($p->url) ->appendTo($channel); - - if ($p->image !== null) { - $item->enclosure($p->image, 0, "image/" . end(explode('.', $p->image))); + + if (!empty($p->image)) { + $item->enclosure($p->image, 0, "image/" . pathinfo($p->image, PATHINFO_EXTENSION)); + } elseif (!empty($img)) { + $item->enclosure($img, 0, "image/" . pathinfo($img, PATHINFO_EXTENSION)); } + } }