]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/Post/Media.php
Some more improvements for posts with shares
[friendica.git] / src / Model / Post / Media.php
index 6d0707743eed1876d09a2f9bf9b76b0e92dfe9ee..37603ad372659b7bb61a989f61f8e2b08f352610 100644 (file)
@@ -404,9 +404,8 @@ class Media
                $unshared_body = $body = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism", '[img]$3[/img]', $body);
 
                // Only remove the shared data from "real" reshares
-               $shared = BBCode::fetchShareAttributes($body);
-               if (!empty($shared['guid'])) {
-                       $unshared_body = preg_replace("/\s*\[share .*?\].*?\[\/share\]\s*/ism", '', $body);
+               if (BBCode::isNativeReshare($body)) {
+                       $unshared_body = BBCode::removeSharedData($body);
                }
 
                $attachments = [];
@@ -486,10 +485,9 @@ class Media
        public static function insertFromRelevantUrl(int $uriid, string $body)
        {
                // Only remove the shared data from "real" reshares
-               $shared = BBCode::fetchShareAttributes($body);
-               if (!empty($shared['guid'])) {
+               if (BBCode::isNativeReshare($body)) {
                        // Don't look at the shared content
-                       $body = preg_replace("/\s*\[share .*?\].*?\[\/share\]\s*/ism", '', $body);
+                       $body = BBCode::removeSharedData($body);
                }
 
                // Remove all hashtags and mentions
@@ -522,7 +520,7 @@ class Media
        public static function insertFromAttachmentData(int $uriid, string $body)
        {
                // Don't look at the shared content
-               $body = preg_replace("/\s*\[share .*?\].*?\[\/share\]\s*/ism", '', $body);
+               $body = BBCode::removeSharedData($body);
 
                $data = BBCode::getAttachmentData($body);
                if (empty($data))  {