]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/Post/Media.php
Merge pull request #11526 from annando/ap-endpoint-cache
[friendica.git] / src / Model / Post / Media.php
index 254b88115cb1f2d1f2754b95e96901336b9effbe..78f27b7a099252380b09821bc3c170d9f2dd17a3 100644 (file)
@@ -30,6 +30,7 @@ use Friendica\DI;
 use Friendica\Model\Item;
 use Friendica\Model\Photo;
 use Friendica\Model\Post;
+use Friendica\Network\HTTPClient\Client\HttpClientAccept;
 use Friendica\Network\HTTPClient\Client\HttpClientOptions;
 use Friendica\Util\Images;
 use Friendica\Util\Network;
@@ -172,7 +173,7 @@ class Media
 
                        // Workaround for systems that can't handle a HEAD request
                        if (!$curlResult->isSuccess() && ($curlResult->getReturnCode() == 405)) {
-                               $curlResult = DI::httpClient()->get($media['url'], [HttpClientOptions::TIMEOUT => $timeout]);
+                               $curlResult = DI::httpClient()->get($media['url'], HttpClientAccept::DEFAULT, [HttpClientOptions::TIMEOUT => $timeout]);
                        }
 
                        if ($curlResult->isSuccess()) {
@@ -546,12 +547,17 @@ class Media
         * @param int    $uri_id
         * @param string $guid
         * @param array  $links list of links that shouldn't be added
+        * @param bool   $has_media
         * @return array attachments
         */
-       public static function splitAttachments(int $uri_id, string $guid = '', array $links = [])
+       public static function splitAttachments(int $uri_id, string $guid = '', array $links = [], bool $has_media = true)
        {
                $attachments = ['visual' => [], 'link' => [], 'additional' => []];
 
+               if (!$has_media) {
+                       return $attachments;
+               }
+
                $media = self::getByURIId($uri_id);
                if (empty($media)) {
                        return $attachments;