From e475cf131d96ac1b9fc82ae598acad811cd9e4aa Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Mon, 1 Dec 2014 22:49:35 +0100 Subject: [PATCH] When a post contains a picture then a picture in the added information is displayed only as a small preview picture. --- include/bbcode.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/include/bbcode.php b/include/bbcode.php index 5395548f51..724b8e2fdd 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -3,10 +3,10 @@ require_once("include/oembed.php"); require_once('include/event.php'); function bb_attachment($Text, $plaintext = false, $tryoembed = true) { - $Text = preg_replace_callback("/\[attachment(.*?)\](.*?)\[\/attachment\]/ism", + $Text = preg_replace_callback("/(.*?)\[attachment(.*?)\](.*?)\[\/attachment\]/ism", function ($match) use ($plaintext){ - $attributes = $match[1]; + $attributes = $match[2]; $type = ""; preg_match("/type='(.*?)'/ism", $attributes, $matches); @@ -65,6 +65,11 @@ function bb_attachment($Text, $plaintext = false, $tryoembed = true) { $preview = $matches[1]; } + if (((strpos($match[1], "[img=") !== false) OR (strpos($match[1], "[img]") !== false)) AND ($image != "")) { + $preview = $image; + $image = ""; + } + if ($plaintext) $text = sprintf('%s
', $url, $title); else { @@ -83,10 +88,10 @@ function bb_attachment($Text, $plaintext = false, $tryoembed = true) { $text .= $oembed; - $text .= sprintf('
%s
', trim($match[2])); + $text .= sprintf('
%s
', trim($match[3])); } - return($text); + return($match[1].$text); },$Text); return($Text);