Align proxy sizes to photo preview sizes

- PIXEL_SMALL goes from 300 to 320
- PIXEL_MEDIUM goes from 600 to 640
- Use Proxy pixel constants where we used hard-coded pixel values
This commit is contained in:
Hypolite Petovan 2023-10-14 15:29:03 -04:00
parent e0d4646c18
commit 938b2bae23
5 changed files with 24 additions and 23 deletions

View file

@ -26,12 +26,12 @@ use Friendica\BaseModule;
use Friendica\Core\L10n;
use Friendica\Core\Renderer;
use Friendica\Core\Session\Capability\IHandleUserSessions;
use Friendica\Core\System;
use Friendica\Model\Photo;
use Friendica\Module\Response;
use Friendica\Network\HTTPException\UnauthorizedException;
use Friendica\Util\Images;
use Friendica\Util\Profiler;
use Friendica\Util\Proxy;
use Friendica\Util\Strings;
use Psr\Log\LoggerInterface;
@ -109,8 +109,8 @@ class Browser extends BaseModule
[
"`resource-id` = ? AND `height` <= ? AND `width` <= ?",
$record['resource-id'],
640,
640
Proxy::PIXEL_MEDIUM,
Proxy::PIXEL_MEDIUM
],
['order' => ['scale']]);
$scale = $photo['scale'] ?? $record['loq'];

View file

@ -30,6 +30,7 @@ use Friendica\Network\HTTPException;
use Friendica\Object\Image;
use Friendica\Util\Images;
use Friendica\Util\Strings;
use Friendica\Util\Proxy;
class Index extends BaseSettings
{
@ -82,7 +83,7 @@ class Index extends BaseSettings
$height = $Image->getHeight();
if ($width < 175 || $height < 175) {
$Image->scaleUp(300);
$Image->scaleUp(Proxy::PIXEL_SMALL);
$width = $Image->getWidth();
$height = $Image->getHeight();
}
@ -95,10 +96,10 @@ class Index extends BaseSettings
DI::sysmsg()->addNotice(DI::l10n()->t('Image upload failed.'));
}
if ($width > 640 || $height > 640) {
$Image->scaleDown(640);
if ($width > Proxy::PIXEL_MEDIUM || $height > Proxy::PIXEL_MEDIUM) {
$Image->scaleDown(Proxy::PIXEL_MEDIUM);
if (!Photo::store($Image, DI::userSession()->getLocalUserId(), 0, $resource_id, $filename, DI::l10n()->t(Photo::PROFILE_PHOTOS), 1, Photo::USER_AVATAR)) {
DI::sysmsg()->addNotice(DI::l10n()->t('Image size reduction [%s] failed.', '640'));
DI::sysmsg()->addNotice(DI::l10n()->t('Image size reduction [%s] failed.', Proxy::PIXEL_MEDIUM));
}
}