]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/Post/Media.php
Rewrite:
[friendica.git] / src / Model / Post / Media.php
index 3b23e5d0fe08db912bb105a4b0545d69cc2eadfc..ce00b205c5deaba28e0cb2461f8bc6bb090ea0e5 100644 (file)
@@ -85,6 +85,7 @@ class Media
                }
 
                $media = self::unsetEmptyFields($media);
+               $media = DI::dbaDefinition()->truncateFieldsForTable('post-media', $media);
 
                // We are storing as fast as possible to avoid duplicated network requests
                // when fetching additional information for pictures and other content.
@@ -94,6 +95,7 @@ class Media
 
                $media = self::fetchAdditionalData($media);
                $media = self::unsetEmptyFields($media);
+               $media = DI::dbaDefinition()->truncateFieldsForTable('post-media', $media);
 
                if (array_diff_assoc($media, $stored)) {
                        $result = DBA::insert('post-media', $media, Database::INSERT_UPDATE);
@@ -646,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]);
@@ -663,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;
                        }