nieuws: hide text after cover image in overviews
[minimedit.git] / nieuws.inc.php
index e2985692018e3db8055a5d596082cefd7a2bc307..b58def7b7302bdad9ac4e41cc7e93c1155d6cbb2 100644 (file)
@@ -78,7 +78,7 @@ class ArchiveArticle
        {
                $this->title;
                $rest = fread($this->file, filesize($this->page));
-               if ( preg_match('{\n<p>(<img [^>]*>)</p>\s*\z}', $rest, $img, PREG_OFFSET_CAPTURE) ) {
+               if ( preg_match('{\n<p>(<img [^>]*>)</p>}', $rest, $img, PREG_OFFSET_CAPTURE) ) {
                        $this->img = $img[1][0];
                        return substr($rest, 0, $img[0][1]);
                }
@@ -114,7 +114,9 @@ function shownews($input, $limit = 1000)
                $article = new ArchiveArticle($filename);
                print '<li>';
                if ($article->thumb) {
-                       printf('<img src="/%s" class="left" />', $article->thumb);
+                       $img = preg_replace('{(?<= \b src="/) [^"]* }x', $article->thumb, $article->img);
+                       $img = preg_replace('{(?= />$)}', ' class="left"', $img);
+                       print $img;
                }
                print '<article>';
                printf(