]> git.mxchange.org Git - friendica.git/commitdiff
When a post contains a picture then a picture in the added information is displayed...
authorMichael Vogel <icarus@dabo.de>
Mon, 1 Dec 2014 21:49:35 +0000 (22:49 +0100)
committerMichael Vogel <icarus@dabo.de>
Mon, 1 Dec 2014 21:49:35 +0000 (22:49 +0100)
include/bbcode.php

index 5395548f51b90279c6497bc2fcdec0c50893a87b..724b8e2fdd1a57cff97cc7748be1209f3ce850e1 100644 (file)
@@ -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('<a href="%s" target="_blank">%s</a><br>', $url, $title);
                        else {
@@ -83,10 +88,10 @@ function bb_attachment($Text, $plaintext = false, $tryoembed = true) {
 
                                $text .= $oembed;
 
-                               $text .= sprintf('<blockquote>%s</blockquote></span>', trim($match[2]));
+                               $text .= sprintf('<blockquote>%s</blockquote></span>', trim($match[3]));
                        }
 
-                       return($text);
+                       return($match[1].$text);
                },$Text);
 
        return($Text);