Merge pull request #13541 from MrPetovan/bug/13534-image-blurred
Drop using the proxy large size for image preview
This commit is contained in:
commit
e99fcfddb5
6 changed files with 26 additions and 28 deletions
|
@ -312,16 +312,16 @@ function photos_post(App $a)
|
||||||
|
|
||||||
Photo::update(['height' => $height, 'width' => $width], ['resource-id' => $resource_id, 'uid' => $page_owner_uid, 'scale' => 0], $image);
|
Photo::update(['height' => $height, 'width' => $width], ['resource-id' => $resource_id, 'uid' => $page_owner_uid, 'scale' => 0], $image);
|
||||||
|
|
||||||
if ($width > 640 || $height > 640) {
|
if ($width > \Friendica\Util\Proxy::PIXEL_MEDIUM || $height > \Friendica\Util\Proxy::PIXEL_MEDIUM) {
|
||||||
$image->scaleDown(640);
|
$image->scaleDown(\Friendica\Util\Proxy::PIXEL_MEDIUM);
|
||||||
$width = $image->getWidth();
|
$width = $image->getWidth();
|
||||||
$height = $image->getHeight();
|
$height = $image->getHeight();
|
||||||
|
|
||||||
Photo::update(['height' => $height, 'width' => $width], ['resource-id' => $resource_id, 'uid' => $page_owner_uid, 'scale' => 1], $image);
|
Photo::update(['height' => $height, 'width' => $width], ['resource-id' => $resource_id, 'uid' => $page_owner_uid, 'scale' => 1], $image);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($width > 320 || $height > 320) {
|
if ($width > \Friendica\Util\Proxy::PIXEL_SMALL || $height > \Friendica\Util\Proxy::PIXEL_SMALL) {
|
||||||
$image->scaleDown(320);
|
$image->scaleDown(\Friendica\Util\Proxy::PIXEL_SMALL);
|
||||||
$width = $image->getWidth();
|
$width = $image->getWidth();
|
||||||
$height = $image->getHeight();
|
$height = $image->getHeight();
|
||||||
|
|
||||||
|
|
|
@ -3483,11 +3483,8 @@ class Item
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($PostMedia->mimetype->type == 'image') {
|
if ($PostMedia->mimetype->type == 'image' || $PostMedia->preview) {
|
||||||
$preview_size = $PostMedia->width > $PostMedia->height ? Proxy::SIZE_MEDIUM : Proxy::SIZE_LARGE;
|
$preview_size = Proxy::SIZE_MEDIUM;
|
||||||
$preview_url = DI::baseUrl() . $PostMedia->getPreviewPath($preview_size);
|
|
||||||
} elseif ($PostMedia->preview) {
|
|
||||||
$preview_size = Proxy::SIZE_LARGE;
|
|
||||||
$preview_url = DI::baseUrl() . $PostMedia->getPreviewPath($preview_size);
|
$preview_url = DI::baseUrl() . $PostMedia->getPreviewPath($preview_size);
|
||||||
} else {
|
} else {
|
||||||
$preview_size = 0;
|
$preview_size = 0;
|
||||||
|
|
|
@ -1255,16 +1255,16 @@ class Photo
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($width > 640 || $height > 640) {
|
if ($width > Proxy::PIXEL_MEDIUM || $height > Proxy::PIXEL_MEDIUM) {
|
||||||
$image->scaleDown(640);
|
$image->scaleDown(Proxy::PIXEL_MEDIUM);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($width > 320 || $height > 320) {
|
if ($width > Proxy::PIXEL_SMALL || $height > Proxy::PIXEL_SMALL) {
|
||||||
$result = self::store($image, $uid, 0, $resource_id, $filename, $album, 1, self::DEFAULT, $allow_cid, $allow_gid, $deny_cid, $deny_gid, $description);
|
$result = self::store($image, $uid, 0, $resource_id, $filename, $album, 1, self::DEFAULT, $allow_cid, $allow_gid, $deny_cid, $deny_gid, $description);
|
||||||
if ($result) {
|
if ($result) {
|
||||||
$preview = 1;
|
$preview = 1;
|
||||||
}
|
}
|
||||||
$image->scaleDown(320);
|
$image->scaleDown(Proxy::PIXEL_SMALL);
|
||||||
$result = self::store($image, $uid, 0, $resource_id, $filename, $album, 2, self::DEFAULT, $allow_cid, $allow_gid, $deny_cid, $deny_gid, $description);
|
$result = self::store($image, $uid, 0, $resource_id, $filename, $album, 2, self::DEFAULT, $allow_cid, $allow_gid, $deny_cid, $deny_gid, $description);
|
||||||
if ($result && ($preview == 0)) {
|
if ($result && ($preview == 0)) {
|
||||||
$preview = 2;
|
$preview = 2;
|
||||||
|
|
|
@ -26,12 +26,12 @@ use Friendica\BaseModule;
|
||||||
use Friendica\Core\L10n;
|
use Friendica\Core\L10n;
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\Core\Session\Capability\IHandleUserSessions;
|
use Friendica\Core\Session\Capability\IHandleUserSessions;
|
||||||
use Friendica\Core\System;
|
|
||||||
use Friendica\Model\Photo;
|
use Friendica\Model\Photo;
|
||||||
use Friendica\Module\Response;
|
use Friendica\Module\Response;
|
||||||
use Friendica\Network\HTTPException\UnauthorizedException;
|
use Friendica\Network\HTTPException\UnauthorizedException;
|
||||||
use Friendica\Util\Images;
|
use Friendica\Util\Images;
|
||||||
use Friendica\Util\Profiler;
|
use Friendica\Util\Profiler;
|
||||||
|
use Friendica\Util\Proxy;
|
||||||
use Friendica\Util\Strings;
|
use Friendica\Util\Strings;
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
|
|
||||||
|
@ -109,8 +109,8 @@ class Browser extends BaseModule
|
||||||
[
|
[
|
||||||
"`resource-id` = ? AND `height` <= ? AND `width` <= ?",
|
"`resource-id` = ? AND `height` <= ? AND `width` <= ?",
|
||||||
$record['resource-id'],
|
$record['resource-id'],
|
||||||
640,
|
Proxy::PIXEL_MEDIUM,
|
||||||
640
|
Proxy::PIXEL_MEDIUM
|
||||||
],
|
],
|
||||||
['order' => ['scale']]);
|
['order' => ['scale']]);
|
||||||
$scale = $photo['scale'] ?? $record['loq'];
|
$scale = $photo['scale'] ?? $record['loq'];
|
||||||
|
|
|
@ -30,6 +30,7 @@ use Friendica\Network\HTTPException;
|
||||||
use Friendica\Object\Image;
|
use Friendica\Object\Image;
|
||||||
use Friendica\Util\Images;
|
use Friendica\Util\Images;
|
||||||
use Friendica\Util\Strings;
|
use Friendica\Util\Strings;
|
||||||
|
use Friendica\Util\Proxy;
|
||||||
|
|
||||||
class Index extends BaseSettings
|
class Index extends BaseSettings
|
||||||
{
|
{
|
||||||
|
@ -82,7 +83,7 @@ class Index extends BaseSettings
|
||||||
$height = $Image->getHeight();
|
$height = $Image->getHeight();
|
||||||
|
|
||||||
if ($width < 175 || $height < 175) {
|
if ($width < 175 || $height < 175) {
|
||||||
$Image->scaleUp(300);
|
$Image->scaleUp(Proxy::PIXEL_SMALL);
|
||||||
$width = $Image->getWidth();
|
$width = $Image->getWidth();
|
||||||
$height = $Image->getHeight();
|
$height = $Image->getHeight();
|
||||||
}
|
}
|
||||||
|
@ -95,10 +96,10 @@ class Index extends BaseSettings
|
||||||
DI::sysmsg()->addNotice(DI::l10n()->t('Image upload failed.'));
|
DI::sysmsg()->addNotice(DI::l10n()->t('Image upload failed.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($width > 640 || $height > 640) {
|
if ($width > Proxy::PIXEL_MEDIUM || $height > Proxy::PIXEL_MEDIUM) {
|
||||||
$Image->scaleDown(640);
|
$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)) {
|
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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,8 +36,8 @@ class Proxy
|
||||||
*/
|
*/
|
||||||
const SIZE_MICRO = 'micro'; // 48
|
const SIZE_MICRO = 'micro'; // 48
|
||||||
const SIZE_THUMB = 'thumb'; // 80
|
const SIZE_THUMB = 'thumb'; // 80
|
||||||
const SIZE_SMALL = 'small'; // 300
|
const SIZE_SMALL = 'small'; // 320
|
||||||
const SIZE_MEDIUM = 'medium'; // 600
|
const SIZE_MEDIUM = 'medium'; // 640
|
||||||
const SIZE_LARGE = 'large'; // 1024
|
const SIZE_LARGE = 'large'; // 1024
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -45,8 +45,8 @@ class Proxy
|
||||||
*/
|
*/
|
||||||
const PIXEL_MICRO = 48;
|
const PIXEL_MICRO = 48;
|
||||||
const PIXEL_THUMB = 80;
|
const PIXEL_THUMB = 80;
|
||||||
const PIXEL_SMALL = 300;
|
const PIXEL_SMALL = 320;
|
||||||
const PIXEL_MEDIUM = 600;
|
const PIXEL_MEDIUM = 640;
|
||||||
const PIXEL_LARGE = 1024;
|
const PIXEL_LARGE = 1024;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue