]> git.mxchange.org Git - friendica.git/blobdiff - src/Content/PageInfo.php
Issue 9657: Check the age of an item
[friendica.git] / src / Content / PageInfo.php
index e4d9207c8c43eaaf7b066978e52b865439d9b7c1..5396bc1bbe96d4d17a3eb55e6d40bf0918b62b76 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'];
+                               }
                        }
                }
 
@@ -261,7 +265,7 @@ class PageInfo
                }
 
                if (!$matches && $searchNakedUrls) {
-                       preg_match('~(?<=\W|^)(?<![=\]])(https?://.+)$~is', $body, $matches);
+                       preg_match(Strings::autoLinkRegEx(), $body, $matches);
                        if ($matches && !Strings::endsWith($body, $matches[1])) {
                                unset($matches);
                        }
@@ -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 '';
                        }