From a332183ffe74a1580779a5eeeeb7dbe02a398075 Mon Sep 17 00:00:00 2001 From: Mischa POSLAWSKY Date: Wed, 1 Aug 2018 00:36:57 +0200 Subject: [PATCH] nieuws: find article image to append on page --- nieuws.inc.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/nieuws.inc.php b/nieuws.inc.php index 3f3f163..454c91c 100644 --- a/nieuws.inc.php +++ b/nieuws.inc.php @@ -14,6 +14,15 @@ function shownewsdate($url) ])); } +function shownewsimage($url) +{ + foreach (['jpg', 'png'] as $ext) { + if (file_exists("$url.$ext")) { + return "$url.$ext"; + } + } +} + function shownewsarticle($url, $link = TRUE, $title = NULL) { $html = ob_get_clean(); @@ -27,6 +36,17 @@ function shownewsarticle($url, $link = TRUE, $title = NULL) getoutput([1 => ' '.$date.'']), $url ); + + if (!$link and $image = shownewsimage($url)) { + global $Place; + $Place['image'] = "https://lijtweg.nl/thumb/600x/".$image; + ob_start(); + print '[[1]]'; + $html .= getoutput([ + 1 => sprintf("\n".'

', "/thumb/640x/".$image), + ]); + } + return preg_replace('{

(.*?)

}', $title, $html); } -- 2.30.0