]> git.mxchange.org Git - friendica.git/commitdiff
Attachments: Better handling of preview pictures
authorMichael Vogel <icarus@dabo.de>
Mon, 18 Apr 2016 10:13:54 +0000 (12:13 +0200)
committerRoland Haeder <roland@mxchange.org>
Sun, 1 May 2016 11:48:52 +0000 (13:48 +0200)
include/plaintext.php

index a6738ca93b5bfb2d33aac1bd3342ad63a9dbc2f9..a4f6b6bf6825d037a132d44762e212458d37468e 100644 (file)
@@ -1,4 +1,7 @@
 <?php
+
+require_once("include/Photo.php");
+
 /**
  * @brief Fetches attachment data that were generated the old way
  *
@@ -31,8 +34,15 @@ function get_old_attachment_data($body) {
 
                        $URLSearchString = "^\[\]";
 
-                       if (preg_match("/\[img\]([$URLSearchString]*)\[\/img\]/ism", $attacheddata, $matches))
-                               $post["image"] = $matches[1];
+                       if (preg_match("/\[img\]([$URLSearchString]*)\[\/img\]/ism", $attacheddata, $matches)) {
+
+                               $picturedata = get_photo_info($matches[1]);
+
+                               if (($picturedata[0] >= 500) AND ($picturedata[0] >= $picturedata[1]))
+                                       $post["image"] = $matches[1];
+                               else
+                                       $post["preview"] = $matches[1];
+                       }
 
                        if (preg_match("/\[bookmark\=([$URLSearchString]*)\](.*?)\[\/bookmark\]/ism", $attacheddata, $matches)) {
                                $post["url"] = $matches[1];
@@ -144,9 +154,7 @@ function get_attachment_data($body) {
                        $preview = $matches[1];
        }
 
-       if (($image == "") AND ($preview != ""))
-               $data["image"] = $preview;
-       else
+       if ($preview != "")
                $data["preview"] = $preview;
 
        $data["description"] = trim($match[3]);