Use a constant for the avatar base path
This commit is contained in:
parent
916aa1c9a9
commit
34030a736d
1 changed files with 6 additions and 4 deletions
|
@ -39,6 +39,8 @@ use Friendica\Util\Strings;
|
||||||
*/
|
*/
|
||||||
class Avatar
|
class Avatar
|
||||||
{
|
{
|
||||||
|
const BASE_PATH = '/avatar/';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a field array with locally cached avatar pictures
|
* Returns a field array with locally cached avatar pictures
|
||||||
*
|
*
|
||||||
|
@ -105,11 +107,11 @@ class Avatar
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
$path = '/avatar/' . $filename . $size . '.' . $image->getExt();
|
$path = self::BASE_PATH . $filename . $size . '.' . $image->getExt();
|
||||||
|
|
||||||
$filepath = DI::basePath() . $path;
|
$filepath = DI::basePath() . $path;
|
||||||
|
|
||||||
$dirpath = DI::basePath() . '/avatar/';
|
$dirpath = DI::basePath() . self::BASE_PATH;
|
||||||
|
|
||||||
DI::profiler()->startRecording('file');
|
DI::profiler()->startRecording('file');
|
||||||
|
|
||||||
|
@ -169,13 +171,13 @@ class Avatar
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
$path = Strings::normaliseLink(DI::baseUrl() . '/avatar');
|
$path = Strings::normaliseLink(DI::baseUrl() . self::BASE_PATH);
|
||||||
|
|
||||||
if (Network::getUrlMatch($path, $avatar) != $path) {
|
if (Network::getUrlMatch($path, $avatar) != $path) {
|
||||||
return '';
|
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');
|
DI::profiler()->startRecording('file');
|
||||||
$exists = file_exists($filename);
|
$exists = file_exists($filename);
|
||||||
|
|
Loading…
Reference in a new issue