From 76ccc52406444379dd10c1bfc5d9962451abf21c Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 9 May 2023 06:32:16 +0000 Subject: [PATCH] Improved variable naming --- src/Model/Photo.php | 22 +++++++++++----------- src/Module/Media/Photo/Upload.php | 6 +++--- src/Module/Profile/Photos.php | 6 +++--- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/Model/Photo.php b/src/Model/Photo.php index 0df45af22..74031a822 100644 --- a/src/Model/Photo.php +++ b/src/Model/Photo.php @@ -1192,8 +1192,8 @@ class Photo $allow_gid = ''; } - $smallest = self::storeWithPreview($image, $user['uid'], $resource_id, $filename, $filesize, $album, $desc, $allow_cid, $allow_gid, $deny_cid, $deny_gid); - if ($smallest < 0) { + $preview = self::storeWithPreview($image, $user['uid'], $resource_id, $filename, $filesize, $album, $desc, $allow_cid, $allow_gid, $deny_cid, $deny_gid); + if ($preview < 0) { Logger::warning('Photo could not be stored', ['uid' => $user['uid'], 'resource_id' => $resource_id, 'filename' => $filename, 'album' => $album]); return []; } @@ -1215,7 +1215,7 @@ class Photo $picture['type'] = $photo['type']; $picture['albumpage'] = DI::baseUrl() . '/photos/' . $user['nickname'] . '/image/' . $resource_id; $picture['picture'] = DI::baseUrl() . '/photo/' . $resource_id . '-0.' . $image->getExt(); - $picture['preview'] = DI::baseUrl() . '/photo/' . $resource_id . '-' . $smallest . '.' . $image->getExt(); + $picture['preview'] = DI::baseUrl() . '/photo/' . $resource_id . '-' . $preview . '.' . $image->getExt(); Logger::info('upload done', ['picture' => $picture]); return $picture; @@ -1236,7 +1236,7 @@ class Photo * @param string $deny_cid Permissions, denied contacts * @param string $deny_gid Permissions, denied group * - * @return boolean True on success + * @return integer preview photo size * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ public static function storeWithPreview(Image $image, int $uid, string $resource_id, string $filename, int $filesize, string $album, string $description, string $allow_cid, string $allow_gid, string $deny_cid, string $deny_gid): int @@ -1268,9 +1268,9 @@ class Photo } } - $width = $image->getWidth(); - $height = $image->getHeight(); - $smallest = 0; + $width = $image->getWidth(); + $height = $image->getHeight(); + $preview = 0; $result = self::store($image, $uid, 0, $resource_id, $filename, $album, 0, self::DEFAULT, $allow_cid, $allow_gid, $deny_cid, $deny_gid, $description); if (!$result) { @@ -1285,15 +1285,15 @@ class Photo if ($width > 320 || $height > 320) { $result = self::store($image, $uid, 0, $resource_id, $filename, $album, 1, self::DEFAULT, $allow_cid, $allow_gid, $deny_cid, $deny_gid, $description); if ($result) { - $smallest = 1; + $preview = 1; } $image->scaleDown(320); $result = self::store($image, $uid, 0, $resource_id, $filename, $album, 2, self::DEFAULT, $allow_cid, $allow_gid, $deny_cid, $deny_gid, $description); - if ($result && ($smallest == 0)) { - $smallest = 2; + if ($result && ($preview == 0)) { + $preview = 2; } } - return $smallest; + return $preview; } /** diff --git a/src/Module/Media/Photo/Upload.php b/src/Module/Media/Photo/Upload.php index 7d7482fcc..09d31971a 100644 --- a/src/Module/Media/Photo/Upload.php +++ b/src/Module/Media/Photo/Upload.php @@ -173,14 +173,14 @@ class Upload extends \Friendica\BaseModule $allow_cid = '<' . $owner['id'] . '>'; - $smallest = Photo::storeWithPreview($image, $owner['uid'], $resource_id, $filename, $filesize, $album, '', $allow_cid, '', '', ''); - if ($smallest < 0) { + $preview = Photo::storeWithPreview($image, $owner['uid'], $resource_id, $filename, $filesize, $album, '', $allow_cid, '', '', ''); + if ($preview < 0) { $this->logger->warning('Photo::store() failed'); $this->return(401, $this->t('Image upload failed.')); } $this->logger->info('upload done'); - $this->return(200, "\n\n" . '[url=' . $this->baseUrl . '/photos/' . $owner['nickname'] . '/image/' . $resource_id . '][img=' . $this->baseUrl . "/photo/$resource_id-$smallest." . $image->getExt() . "][/img][/url]\n\n"); + $this->return(200, "\n\n" . '[url=' . $this->baseUrl . '/photos/' . $owner['nickname'] . '/image/' . $resource_id . '][img=' . $this->baseUrl . "/photo/$resource_id-$preview." . $image->getExt() . "][/img][/url]\n\n"); } /** diff --git a/src/Module/Profile/Photos.php b/src/Module/Profile/Photos.php index 8e826bd91..03937c655 100644 --- a/src/Module/Profile/Photos.php +++ b/src/Module/Profile/Photos.php @@ -231,8 +231,8 @@ class Photos extends \Friendica\Module\BaseProfile $resource_id = Photo::newResource(); - $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) { + $preview = Photo::storeWithPreview($image, $this->owner['uid'], $resource_id, $filename, $filesize, $album, '', $str_contact_allow, $str_group_allow, $str_contact_deny, $str_group_deny); + if ($preview < 0) { $this->logger->warning('image store failed'); $this->systemMessages->addNotice($this->t('Image upload failed.')); return; @@ -274,7 +274,7 @@ class Photos extends \Friendica\Module\BaseProfile $arr['origin'] = 1; $arr['body'] = '[url=' . $this->baseUrl . '/photos/' . $this->owner['nickname'] . '/image/' . $resource_id . ']' - . '[img]' . $this->baseUrl . "/photo/{$resource_id}-{$smallest}.".$image->getExt() . '[/img]' + . '[img]' . $this->baseUrl . "/photo/{$resource_id}-{$preview}.".$image->getExt() . '[/img]' . '[/url]'; $item_id = Item::insert($arr);