nieuws: disregard unwanted image attributes in overviews
authorMischa POSLAWSKY <perl@shiar.org>
Tue, 12 Feb 2019 00:28:59 +0000 (01:28 +0100)
committerMischa POSLAWSKY <perl@shiar.org>
Sat, 2 Mar 2019 15:00:32 +0000 (16:00 +0100)
Only alt is wanted; styling such as class will disrupt layout.

nieuws.inc.php

index 6d84d1ac54b5930a19f2f26af75dcc13a96d6c14..cafd4ecddc422ed6edb18d0543cf95b810188db3 100644 (file)
@@ -120,9 +120,11 @@ function shownews($input, $limit = 1000)
                $article = new ArchiveArticle($filename);
                print '<article class="left">';
                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('<img src="/%s"%s />', $article->thumb, $imgattr);
                }
                print '<div>';
                printf(