]> git.mxchange.org Git - friendica.git/commitdiff
Only attach images
authorMichael <heluecht@pirati.ca>
Tue, 11 Oct 2022 21:39:28 +0000 (21:39 +0000)
committerMichael <heluecht@pirati.ca>
Tue, 11 Oct 2022 21:39:28 +0000 (21:39 +0000)
src/Content/Item.php
src/Model/Post/Media.php

index 1b07c5585cd3fa578f5450986ee62e17e836afe5..d1cdbc679b7ab36dbe4889816eb068eeb2986ecf 100644 (file)
@@ -668,7 +668,7 @@ class Item
 
                $shared = BBCode::fetchShareAttributes($item['body']);
 
-               $item['body'] = Post\Media::addAttachmentsToBody($item['uri-id'], $item['body']);
+               $item['body'] = Post\Media::addAttachmentsToBody($item['uri-id'], $item['body'], [Post\Media::IMAGE]);
 
                // If it is a reshared post then reformat it to avoid display problems with two share elements
                if (Diaspora::isReshare($item['body'], false)) {
index 8fb10ddd88868c64d5090a83c0f6b72421f39cfd..ce00b205c5deaba28e0cb2461f8bc6bb090ea0e5 100644 (file)
@@ -648,11 +648,13 @@ class Media
        /**
         * Add media attachments to the body
         *
-        * @param int $uriid
+        * @param int    $uriid
         * @param string $body
+        * @param array  $types
+        *
         * @return string body
         */
-       public static function addAttachmentsToBody(int $uriid, string $body = ''): string
+       public static function addAttachmentsToBody(int $uriid, string $body = '', array $types = [self::IMAGE, self::AUDIO, self::VIDEO]): string
        {
                if (empty($body)) {
                        $item = Post::selectFirst(['body'], ['uri-id' => $uriid]);
@@ -665,7 +667,7 @@ class Media
 
                $body = preg_replace("/\s*\[attachment .*?\].*?\[\/attachment\]\s*/ism", '', $body);
 
-               foreach (self::getByURIId($uriid, [self::IMAGE, self::AUDIO, self::VIDEO]) as $media) {
+               foreach (self::getByURIId($uriid, $types) as $media) {
                        if (Item::containsLink($body, $media['preview'] ?? $media['url'], $media['type'])) {
                                continue;
                        }