From 10104430313887e825db2f2e61b5bf46ffe95a60 Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 17 May 2023 20:30:45 +0000 Subject: [PATCH] Simplify image url --- src/Content/Text/HTML.php | 1 - src/Model/Post/Media.php | 2 +- src/Module/Media/Photo/Upload.php | 2 +- src/Util/Images.php | 16 ++++------------ 4 files changed, 6 insertions(+), 15 deletions(-) diff --git a/src/Content/Text/HTML.php b/src/Content/Text/HTML.php index 3f9ef7c3b4..988274f8dc 100644 --- a/src/Content/Text/HTML.php +++ b/src/Content/Text/HTML.php @@ -24,7 +24,6 @@ namespace Friendica\Content\Text; use DOMDocument; use DOMXPath; use Friendica\Protocol\HTTP\MediaType; -use Friendica\Content\Widget\ContactBlock; use Friendica\Core\Hook; use Friendica\Core\Renderer; use Friendica\Core\Search; diff --git a/src/Model/Post/Media.php b/src/Model/Post/Media.php index e040f2b113..a0d55b6e00 100644 --- a/src/Model/Post/Media.php +++ b/src/Model/Post/Media.php @@ -1004,7 +1004,7 @@ class Media } if ($media['type'] == self::IMAGE) { - $body .= "\n" . Images::getBBCodeByUrl($media['url'], $media['preview'], $media['description']); + $body .= "\n" . Images::getBBCodeByUrl($media['url'], $media['preview'], $media['description'] ?? ''); } elseif ($media['type'] == self::AUDIO) { $body .= "\n[audio]" . $media['url'] . "[/audio]\n"; } elseif ($media['type'] == self::VIDEO) { diff --git a/src/Module/Media/Photo/Upload.php b/src/Module/Media/Photo/Upload.php index 25f9af9bc0..e53ca35b86 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 7f6d8720ff..aed72f065b 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 = null): string + public static function getBBCodeByResource(string $resource_id, string $nickname, int $preview, string $ext, string $description = ''): string { return self::getBBCodeByUrl( DI::baseUrl() . '/photos/' . $nickname . '/image/' . $resource_id, @@ -344,20 +344,12 @@ class Images * @param string $description * @return string */ - public static function getBBCodeByUrl(string $photo, string $preview = null, string $description = null): string + public static function getBBCodeByUrl(string $photo, string $preview = null, string $description = ''): string { if (!empty($preview)) { - if (!is_null($description)) { - return '[url=' . $photo . '][img=' . $preview . ']' . $description . '[/img][/url]'; - } else { - return '[url=' . $photo . '][img]' . $preview . '[/img][/url]'; - } + return '[url=' . $photo . '][img=' . $preview . ']' . $description . '[/img][/url]'; } - if (!is_null($description)) { - return '[img=' . $photo . ']' . $description . '[/img]'; - } else { - return '[img]' . $photo . '[/img]'; - } + return '[img=' . $photo . ']' . $description . '[/img]'; } } -- 2.39.5