X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModel%2FPhoto.php;h=9623f5622eabf849292bd45f25bae99c82136306;hb=21f172c585aff8c606774a05fde1548ddff1667d;hp=1250ad570b64bce65a10e573fbf9e4bb8d449a3a;hpb=97a3587e5821d6d2208d38941b36118e7da17059;p=friendica.git diff --git a/src/Model/Photo.php b/src/Model/Photo.php index 1250ad570b..9623f5622e 100644 --- a/src/Model/Photo.php +++ b/src/Model/Photo.php @@ -1,6 +1,6 @@ $url, 'uid' => $uid]); $photo['type'] = $mimetype; $photo['cacheable'] = true; + $photo['blurhash'] = $blurhash; + $photo['width'] = $width; + $photo['height'] = $height; return $photo; } @@ -436,6 +464,7 @@ class Photo 'height' => $image->getHeight(), 'width' => $image->getWidth(), 'datasize' => strlen($image->asString()), + 'blurhash' => $image->getBlurHash(), 'data' => $data, 'scale' => $scale, 'photo-type' => $type, @@ -577,11 +606,7 @@ class Photo $filesize = strlen($image->asString()); $maximagesize = Strings::getBytesFromShorthand(DI::config()->get('system', 'maximagesize')); - if ($maximagesize == 0) { - $maximagesize = INF; - } - - if (!empty($maximagesize) && ($filesize > $maximagesize)) { + if ($maximagesize && ($filesize > $maximagesize)) { Logger::info('Avatar exceeds image limit', ['uid' => $uid, 'cid' => $cid, 'maximagesize' => $maximagesize, 'size' => $filesize, 'type' => $image->getType()]); if ($image->getType() == 'image/gif') { $image->toStatic(); @@ -644,7 +669,11 @@ class Photo $micro = Contact::getDefaultAvatar($contact, Proxy::SIZE_MICRO); } - return [$image_url, $thumb, $micro]; + $photo = DBA::selectFirst( + 'photo', ['blurhash'], ['uid' => $uid, 'contact-id' => $cid, 'scale' => 4, 'photo-type' => self::CONTACT_AVATAR] + ); + + return [$image_url, $thumb, $micro, $photo['blurhash']]; } /** @@ -973,11 +1002,7 @@ class Photo $maximagesize = Strings::getBytesFromShorthand(DI::config()->get('system', 'maximagesize')); - if ($maximagesize == 0) { - $maximagesize = INF; - } - - if (!empty($maximagesize) && ($filesize > $maximagesize)) { + if ($maximagesize && ($filesize > $maximagesize)) { // Scale down to multiples of 640 until the maximum size isn't exceeded anymore foreach ([5120, 2560, 1280, 640] as $pixels) { if (($filesize > $maximagesize) && (max($width, $height) > $pixels)) { @@ -1326,7 +1351,7 @@ class Photo logger::warning('profile banner upload with scale 3 (960) failed'); } - logger::info('new profile banner upload ended'); + logger::info('new profile banner upload ended', ['uid' => $uid, 'resource_id' => $resource_id, 'filename' => $filename]); $condition = ["`photo-type` = ? AND `resource-id` != ? AND `uid` = ?", self::USER_BANNER, $resource_id, $uid]; self::update(['photo-type' => self::DEFAULT], $condition);