From f46f7a3b080b947af711ab35601c26f6423cbe8b Mon Sep 17 00:00:00 2001 From: Mischa POSLAWSKY Date: Tue, 12 Feb 2019 01:28:59 +0100 Subject: [PATCH] nieuws: disregard unwanted image attributes in overviews Only alt is wanted; styling such as class will disrupt layout. --- nieuws.inc.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/nieuws.inc.php b/nieuws.inc.php index 6d84d1a..cafd4ec 100644 --- a/nieuws.inc.php +++ b/nieuws.inc.php @@ -120,9 +120,11 @@ function shownews($input, $limit = 1000) $article = new ArchiveArticle($filename); print '
'; if ($article->thumb) { - $img = preg_replace('{(?<= \b src="/) [^"]* }x', $article->thumb, $article->img); - $img = preg_replace('{(?= />$)}', ' class="left"', $img); - print $img; + $imgattr = ' class="left"'; + if (preg_match('{ (\s alt="[^"]+") }x', $article->img, $img)) { + $imgattr .= $img[0]; # preserve alt value + } + printf('', $article->thumb, $imgattr); } print '
'; printf( -- 2.30.0