]> git.mxchange.org Git - friendica.git/blobdiff - src/Content/PageInfo.php
Merge pull request #9613 from annando/issue-8605
[friendica.git] / src / Content / PageInfo.php
index e4d9207c8c43eaaf7b066978e52b865439d9b7c1..786385c3ef7d4a841efb372650e31ce07cf91fb3 100644 (file)
@@ -134,14 +134,6 @@ class PageInfo
 
                $text = "[attachment type='" . $data['type'] . "'";
 
-               if (empty($data['text'])) {
-                       $data['text'] = $data['title'];
-               }
-
-               if (empty($data['text'])) {
-                       $data['text'] = $data['url'];
-               }
-
                if (!empty($data['url'])) {
                        $text .= " url='" . $data['url'] . "'";
                }
@@ -150,6 +142,10 @@ class PageInfo
                        $text .= " title='" . $data['title'] . "'";
                }
 
+               if (empty($data['text'])) {
+                       $data['text'] = '';
+               }
+
                // Only embedd a picture link when it seems to be a valid picture ("width" is set)
                if (!empty($data['images']) && !empty($data['images'][0]['width'])) {
                        $preview = str_replace(['[', ']'], ['[', ']'], htmlentities($data['images'][0]['src'], ENT_QUOTES, 'UTF-8', false));
@@ -160,6 +156,14 @@ class PageInfo
                                $text .= " image='" . $preview . "'";
                        } else {
                                $text .= " preview='" . $preview . "'";
+
+                               if (empty($data['text'])) {
+                                       $data['text'] = $data['title'];
+                               }
+               
+                               if (empty($data['text'])) {
+                                       $data['text'] = $data['url'];
+                               }
                        }
                }
 
@@ -288,7 +292,7 @@ class PageInfo
                        $quotedUrl
                )$#isx", function ($match) use ($url) {
                        // Stripping URLs with no label
-                       if (!isset($match[1])) {
+                       if (empty($match[1])) {
                                return '';
                        }