]> git.mxchange.org Git - friendica.git/blobdiff - src/Content/Item.php
Fix attached media in quoted posts
[friendica.git] / src / Content / Item.php
index 53ee1462f395622d8c8758c541303227018e26ad..7a86135f9fe3f1755ac0b94a364d10964437015a 100644 (file)
@@ -657,7 +657,6 @@ class Item
        public function createSharedBlockByArray(array $item): string
        {
                if (!in_array($item['network'] ?? '', Protocol::FEDERATED)) {
-                       $item['guid'] = '';
                        $item['uri']  = '';
                }
 
@@ -667,8 +666,19 @@ class Item
                        $shared_content .= '[h3]' . $item['title'] . "[/h3]\n";
                }
 
+               $shared = BBCode::fetchShareAttributes($item['body']);
+
+               $item['body'] = Post\Media::addAttachmentsToBody($item['uri-id'], $item['body']);
+
                // If it is a reshared post then reformat it to avoid display problems with two share elements
                if (Diaspora::isReshare($item['body'], false)) {
+                       if (!empty($shared['guid'])) {
+                               $encaspulated_share = self::createSharedPostByGuid($shared['guid']);
+                               if (!empty($encaspulated_share)) {
+                                       $item['body'] = preg_replace("/\[share.*?\](.*)\[\/share\]/ism", $encaspulated_share, $item['body']);
+                               }
+                       }
+       
                        $item['body'] = HTML::toBBCode(BBCode::convertForUriId($item['uri-id'], $item['body'], BBCode::ACTIVITYPUB));
                }