From 2b3c1972db987ee2396e528476739f4cec4e8972 Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 10 May 2023 17:59:25 +0000 Subject: [PATCH] Differentiate between no description or an empty description --- src/Module/Media/Photo/Upload.php | 2 +- src/Util/Images.php | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/Module/Media/Photo/Upload.php b/src/Module/Media/Photo/Upload.php index e53ca35b86..25f9af9bc0 100644 --- a/src/Module/Media/Photo/Upload.php +++ b/src/Module/Media/Photo/Upload.php @@ -179,7 +179,7 @@ class Upload extends \Friendica\BaseModule } $this->logger->info('upload done'); - $this->return(200, "\n\n" . Images::getBBCodeByResource($resource_id, $owner['nickname'], $preview, $image->getExt()) . "\n\n"); + $this->return(200, "\n\n" . Images::getBBCodeByResource($resource_id, $owner['nickname'], $preview, $image->getExt(), '') . "\n\n"); } /** diff --git a/src/Util/Images.php b/src/Util/Images.php index 269dbda199..7f6d8720ff 100644 --- a/src/Util/Images.php +++ b/src/Util/Images.php @@ -327,7 +327,7 @@ class Images * @param string $description * @return string */ - public static function getBBCodeByResource(string $resource_id, string $nickname, int $preview, string $ext, string $description = ''): string + public static function getBBCodeByResource(string $resource_id, string $nickname, int $preview, string $ext, string $description = null): string { return self::getBBCodeByUrl( DI::baseUrl() . '/photos/' . $nickname . '/image/' . $resource_id, @@ -347,8 +347,17 @@ class Images public static function getBBCodeByUrl(string $photo, string $preview = null, string $description = null): string { if (!empty($preview)) { - return '[url=' . $photo . '][img=' . $preview . ']' . $description . '[/img][/url]'; + if (!is_null($description)) { + return '[url=' . $photo . '][img=' . $preview . ']' . $description . '[/img][/url]'; + } else { + return '[url=' . $photo . '][img]' . $preview . '[/img][/url]'; + } + } + + if (!is_null($description)) { + return '[img=' . $photo . ']' . $description . '[/img]'; + } else { + return '[img]' . $photo . '[/img]'; } - return '[img=' . $photo . ']' . $description . '[/img]'; } } -- 2.39.5