Unifiy storing of photos with previews

This commit is contained in:
Michael 2023-05-09 05:29:05 +00:00
parent 1789266859
commit d83073f2a2
3 changed files with 82 additions and 95 deletions

View file

@ -229,38 +229,15 @@ class Photos extends \Friendica\Module\BaseProfile
$image->scaleDown($max_length);
}
$width = $image->getWidth();
$height = $image->getHeight();
$smallest = 0;
$resource_id = Photo::newResource();
$r = Photo::store($image, $this->owner['uid'], 0, $resource_id, $filename, $album, 0 , Photo::DEFAULT, $str_contact_allow, $str_group_allow, $str_contact_deny, $str_group_deny);
if (!$r) {
$smallest = Photo::storeWithPreview($image, $this->owner['uid'], $resource_id, $filename, $filesize, $album, '', $str_contact_allow, $str_group_allow, $str_contact_deny, $str_group_deny);
if ($smallest < 0) {
$this->logger->warning('image store failed');
$this->systemMessages->addNotice($this->t('Image upload failed.'));
return;
}
if ($width > 640 || $height > 640) {
$image->scaleDown(640);
}
if ($width > 320 || $height > 320) {
$result = Photo::store($image, $this->owner['uid'], 0, $resource_id, $filename, $album, 1, Photo::DEFAULT, $str_contact_allow, $str_group_allow, $str_contact_deny, $str_group_deny);
if ($result) {
$smallest = 1;
}
$image->scaleDown(320);
$result = Photo::store($image, $this->owner['uid'], 0, $resource_id, $filename, $album, 2, Photo::DEFAULT, $str_contact_allow, $str_group_allow, $str_contact_deny, $str_group_deny);
if ($result && ($smallest == 0)) {
$smallest = 2;
}
}
$uri = Item::newURI();
// Create item container