]> git.mxchange.org Git - friendica.git/commitdiff
Issue 12858: Peertube avatars can now be fetched
authorMichael <heluecht@pirati.ca>
Sat, 18 Mar 2023 06:41:35 +0000 (06:41 +0000)
committerMichael <heluecht@pirati.ca>
Sat, 18 Mar 2023 06:41:35 +0000 (06:41 +0000)
src/Model/APContact.php
src/Util/Images.php

index 20457b46e838c407bb78dd3c52b0bb4cc954b074..dc062fe5b506afd222a92f7b4f8c75f70d413a0b 100644 (file)
@@ -29,7 +29,6 @@ use Friendica\Core\System;
 use Friendica\Database\DBA;
 use Friendica\DI;
 use Friendica\Model\Item;
-use Friendica\Network\HTTPClient\Client\HttpClientAccept;
 use Friendica\Network\HTTPException;
 use Friendica\Network\Probe;
 use Friendica\Protocol\ActivityNamespace;
@@ -259,6 +258,11 @@ class APContact
                $apcontact['photo'] = JsonLD::fetchElement($compacted, 'as:icon', '@id');
                if (is_array($apcontact['photo']) || !empty($compacted['as:icon']['as:url']['@id'])) {
                        $apcontact['photo'] = JsonLD::fetchElement($compacted['as:icon'], 'as:url', '@id');
+               } elseif (empty($apcontact['photo'])) {
+                       $photo = JsonLD::fetchElementArray($compacted, 'as:icon', 'as:url');
+                       if (!empty($photo[0]['@id'])) {
+                               $apcontact['photo'] = $photo[0]['@id'];
+                       }
                }
 
                $apcontact['header'] = JsonLD::fetchElement($compacted, 'as:image', '@id');
index 6874d36e9bc3e7d93fd8e719fbd37b7b9744c929..90d120081b66527e5682f2860e8b94dec5c7766a 100644 (file)
@@ -229,7 +229,12 @@ class Images
                }
 
                if (empty($img_str)) {
-                       $img_str = DI::httpClient()->fetch($url, HttpClientAccept::IMAGE, 4);
+                       try {
+                               $img_str = DI::httpClient()->fetch($url, HttpClientAccept::IMAGE, 4);
+                       } catch (\Exception $exception) {
+                               Logger::notice('Image is invalid', ['url' => $url, 'exception' => $exception]);
+                               return [];
+                       }
                }
 
                if (!$img_str) {