X-Git-Url: http://git.shiar.net/minimedit.git/blobdiff_plain/1428caff970f73f026f1467c7741798ca7c9272c..d36426d95814cc0a5361c1310adbaff064d9b6f7:/nieuws.inc.php
diff --git a/nieuws.inc.php b/nieuws.inc.php
index 40313e4..1a68993 100644
--- a/nieuws.inc.php
+++ b/nieuws.inc.php
@@ -78,16 +78,27 @@ class ArchiveArticle
{
$this->title;
$rest = fread($this->file, filesize($this->page));
- if ( preg_match('{\n
(
]*>)
}', $rest, $img, PREG_OFFSET_CAPTURE) ) {
- $this->img = $img[1][0];
+ if ( preg_match('{
+ \n (?: < (?: p | figure [^>]* ) >\s* )+ (
]*>) | \n
+ }x', $rest, $img, PREG_OFFSET_CAPTURE) ) {
+ if (isset($img[1])) {
+ $this->img = $img[1][0];
+ }
return substr($rest, 0, $img[0][1]);
}
- $this->img = NULL;
return $rest;
}
+ function teaser()
+ {
+ if (preg_match('{(.*?)
}s', $this->body, $bodyp)) {
+ return $bodyp[1];
+ }
+ }
+
function img()
{
+ $this->img = NULL;
$this->body;
return $this->img;
}
@@ -113,9 +124,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(