Use a constant for the profile photo album

This commit is contained in:
Michael 2021-10-14 04:12:00 +00:00
parent f05fecaec1
commit a33185f835
7 changed files with 17 additions and 53 deletions

View file

@ -45,6 +45,7 @@ use Friendica\Util\Strings;
class Photo
{
const CONTACT_PHOTOS = 'Contact Photos';
const PROFILE_PHOTOS = 'Profile Photos';
const DEFAULT = 0;
const USER_AVATAR = 10;
@ -563,25 +564,6 @@ class Photo
$image_url = DI::baseUrl() . "/photo/" . $resource_id . "-4." . $Image->getExt() . $suffix;
$thumb = DI::baseUrl() . "/photo/" . $resource_id . "-5." . $Image->getExt() . $suffix;
$micro = DI::baseUrl() . "/photo/" . $resource_id . "-6." . $Image->getExt() . $suffix;
// Remove the cached photo
$a = DI::app();
$basepath = $a->getBasePath();
if (is_dir($basepath . "/photo")) {
$filename = $basepath . "/photo/" . $resource_id . "-4." . $Image->getExt();
if (file_exists($filename)) {
unlink($filename);
}
$filename = $basepath . "/photo/" . $resource_id . "-5." . $Image->getExt();
if (file_exists($filename)) {
unlink($filename);
}
$filename = $basepath . "/photo/" . $resource_id . "-6." . $Image->getExt();
if (file_exists($filename)) {
unlink($filename);
}
}
} else {
$photo_failure = true;
}

View file

@ -1161,7 +1161,7 @@ class User
$resource_id = Photo::newResource();
$r = Photo::store($Image, $uid, 0, $resource_id, $filename, DI::l10n()->t('Profile Photos'), 4);
$r = Photo::store($Image, $uid, 0, $resource_id, $filename, DI::l10n()->t(Photo::PROFILE_PHOTOS), 4);
if ($r === false) {
$photo_failure = true;
@ -1169,7 +1169,7 @@ class User
$Image->scaleDown(80);
$r = Photo::store($Image, $uid, 0, $resource_id, $filename, DI::l10n()->t('Profile Photos'), 5);
$r = Photo::store($Image, $uid, 0, $resource_id, $filename, DI::l10n()->t(Photo::PROFILE_PHOTOS), 5);
if ($r === false) {
$photo_failure = true;
@ -1177,7 +1177,7 @@ class User
$Image->scaleDown(48);
$r = Photo::store($Image, $uid, 0, $resource_id, $filename, DI::l10n()->t('Profile Photos'), 6);
$r = Photo::store($Image, $uid, 0, $resource_id, $filename, DI::l10n()->t(Photo::PROFILE_PHOTOS), 6);
if ($r === false) {
$photo_failure = true;