PROFILE_PHOTOS is mostly removed and replaced

This commit is contained in:
Michael 2021-10-19 19:15:28 +00:00
parent ee5fb6238c
commit 3781b34272
8 changed files with 61 additions and 53 deletions

View file

@ -104,6 +104,8 @@ class Crop extends BaseSettings
);
if ($r === false) {
notice(DI::l10n()->t('Image size reduction [%s] failed.', '300'));
} else {
Photo::update(['profile' => true], ['id' => $r['id']]);
}
$Image->scaleDown(80);
@ -120,6 +122,8 @@ class Crop extends BaseSettings
);
if ($r === false) {
notice(DI::l10n()->t('Image size reduction [%s] failed.', '80'));
} else {
Photo::update(['profile' => true], ['id' => $r['id']]);
}
$Image->scaleDown(48);
@ -136,6 +140,8 @@ class Crop extends BaseSettings
);
if ($r === false) {
notice(DI::l10n()->t('Image size reduction [%s] failed.', '48'));
} else {
Photo::update(['profile' => true], ['id' => $r['id']]);
}
Contact::updateSelfFromUserID(local_user(), true);
@ -176,7 +182,7 @@ class Crop extends BaseSettings
// set an already uloaded photo as profile photo
// if photo is in 'Profile Photos', change it in db
if ($photos[0]['album'] == DI::l10n()->t(Photo::PROFILE_PHOTOS) && $havescale) {
if ($photos[0]['photo-type'] == Photo::USER_AVATAR && $havescale) {
Photo::update(['profile' => false], ['uid' => local_user()]);
Photo::update(['profile' => true], ['resource-id' => $resource_id, 'uid' => local_user()]);

View file

@ -92,13 +92,13 @@ class Index extends BaseSettings
$filename = '';
if (!Photo::store($Image, local_user(), 0, $resource_id, $filename, DI::l10n()->t(Photo::PROFILE_PHOTOS), 0)) {
if (!Photo::store($Image, local_user(), 0, $resource_id, $filename, DI::l10n()->t(Photo::PROFILE_PHOTOS), 0, Photo::USER_AVATAR)) {
notice(DI::l10n()->t('Image upload failed.'));
}
if ($width > 640 || $height > 640) {
$Image->scaleDown(640);
if (!Photo::store($Image, local_user(), 0, $resource_id, $filename, DI::l10n()->t(Photo::PROFILE_PHOTOS), 1)) {
if (!Photo::store($Image, local_user(), 0, $resource_id, $filename, DI::l10n()->t(Photo::PROFILE_PHOTOS), 1, Photo::USER_AVATAR)) {
notice(DI::l10n()->t('Image size reduction [%s] failed.', '640'));
}
}