From 34030a736d5e0aa2195c0f472cf69f863c161d83 Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 9 May 2022 19:16:14 +0000 Subject: [PATCH] Use a constant for the avatar base path --- src/Contact/Avatar.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Contact/Avatar.php b/src/Contact/Avatar.php index 8aa72bf9ba..6377560962 100644 --- a/src/Contact/Avatar.php +++ b/src/Contact/Avatar.php @@ -39,6 +39,8 @@ use Friendica\Util\Strings; */ class Avatar { + const BASE_PATH = '/avatar/'; + /** * Returns a field array with locally cached avatar pictures * @@ -105,11 +107,11 @@ class Avatar return ''; } - $path = '/avatar/' . $filename . $size . '.' . $image->getExt(); + $path = self::BASE_PATH . $filename . $size . '.' . $image->getExt(); $filepath = DI::basePath() . $path; - $dirpath = DI::basePath() . '/avatar/'; + $dirpath = DI::basePath() . self::BASE_PATH; DI::profiler()->startRecording('file'); @@ -169,13 +171,13 @@ class Avatar return ''; } - $path = Strings::normaliseLink(DI::baseUrl() . '/avatar'); + $path = Strings::normaliseLink(DI::baseUrl() . self::BASE_PATH); if (Network::getUrlMatch($path, $avatar) != $path) { return ''; } - $filename = str_replace($path, DI::basePath(). '/avatar/', Strings::normaliseLink($avatar)); + $filename = str_replace($path, DI::basePath(). self::BASE_PATH, Strings::normaliseLink($avatar)); DI::profiler()->startRecording('file'); $exists = file_exists($filename); -- 2.39.5