X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModel%2FPhoto.php;h=9623f5622eabf849292bd45f25bae99c82136306;hb=21f172c585aff8c606774a05fde1548ddff1667d;hp=990fb7e616b9f2cb968bf8adbb4477d7afba6732;hpb=2035a7a178042a1c69c9522c9483f29c218df2a1;p=friendica.git diff --git a/src/Model/Photo.php b/src/Model/Photo.php index 990fb7e616..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, @@ -575,8 +604,9 @@ class Photo $image->scaleToSquare(300); $filesize = strlen($image->asString()); - $maximagesize = DI::config()->get('system', 'maximagesize'); - if (!empty($maximagesize) && ($filesize > $maximagesize)) { + $maximagesize = Strings::getBytesFromShorthand(DI::config()->get('system', '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(); @@ -639,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']]; } /** @@ -966,9 +1000,9 @@ class Photo $width = $image->getWidth(); $height = $image->getHeight(); - $maximagesize = DI::config()->get('system', 'maximagesize'); + $maximagesize = Strings::getBytesFromShorthand(DI::config()->get('system', 'maximagesize')); - 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)) { @@ -1317,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);