]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/Photo.php
Issue 9584: Only search posts from federated networks
[friendica.git] / src / Model / Photo.php
index 5f8551fa2708a70c7c8338df36b81bb578988708..0f03b54b0dbac9677dfaca7ee2cb48a6211f5e76 100644 (file)
@@ -32,6 +32,7 @@ use Friendica\Object\Image;
 use Friendica\Util\DateTimeFormat;
 use Friendica\Util\Images;
 use Friendica\Security\Security;
+use Friendica\Util\Proxy;
 use Friendica\Util\Strings;
 
 require_once "include/dba.php";
@@ -422,19 +423,18 @@ class Photo
 
                $filename = basename($image_url);
                if (!empty($image_url)) {
-                       $ret = DI::httpRequest()->get($image_url, true);
+                       $ret = DI::httpRequest()->get($image_url);
                        $img_str = $ret->getBody();
-                       $contType = $ret->getContentType();
+                       $type = $ret->getContentType();
                } else {
                        $img_str = '';
-                       $contType = '';
                }
 
                if ($quit_on_error && ($img_str == "")) {
                        return false;
                }
 
-               $type = Images::getMimeTypeByData($img_str, $image_url, $contType);
+               $type = Images::getMimeTypeByData($img_str, $image_url, $type);
 
                $Image = new Image($img_str, $type);
                if ($Image->isValid()) {
@@ -495,9 +495,10 @@ class Photo
                }
 
                if ($photo_failure) {
-                       $image_url = DI::baseUrl() . Contact::DEFAULT_AVATAR_PHOTO;
-                       $thumb = DI::baseUrl() . Contact::DEFAULT_AVATAR_THUMB;
-                       $micro = DI::baseUrl() . Contact::DEFAULT_AVATAR_MICRO;
+                       $contact = Contact::getById($cid) ?: [];
+                       $image_url = Contact::getDefaultAvatar($contact, Proxy::SIZE_SMALL);
+                       $thumb = Contact::getDefaultAvatar($contact, Proxy::SIZE_THUMB);
+                       $micro = Contact::getDefaultAvatar($contact, Proxy::SIZE_MICRO);
                }
 
                return [$image_url, $thumb, $micro];