Switch uid with nickname in user picture URLs
- Keep previous URL scheme fallback as remote contact avatar URLs pointing to local user avatar URLs need to update
This commit is contained in:
parent
7cdd2d1336
commit
8cb0bb5deb
3 changed files with 33 additions and 14 deletions
|
@ -879,7 +879,7 @@ class User
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $url . $user['uid'] . image_type_to_extension($imagetype) . ($updated ? '?ts=' . strtotime($updated) : '');
|
return $url . $user['nickname'] . image_type_to_extension($imagetype) . ($updated ? '?ts=' . strtotime($updated) : '');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -75,16 +75,31 @@ class Photo extends BaseModule
|
||||||
$square_resize = true;
|
$square_resize = true;
|
||||||
$scale = null;
|
$scale = null;
|
||||||
$stamp = microtime(true);
|
$stamp = microtime(true);
|
||||||
if (!empty($parameters['customsize'])) {
|
// User avatar
|
||||||
$customsize = intval($parameters['customsize']);
|
if (!empty($parameters['type'])) {
|
||||||
$uid = pathinfo($parameters['name'], PATHINFO_FILENAME);
|
if (!empty($parameters['customsize'])) {
|
||||||
$photo = self::getAvatar($uid, $parameters['type'], $customsize);
|
$customsize = intval($parameters['customsize']);
|
||||||
$square_resize = !in_array($parameters['type'], ['media', 'preview']);
|
$square_resize = !in_array($parameters['type'], ['media', 'preview']);
|
||||||
} elseif (!empty($parameters['type'])) {
|
}
|
||||||
$uid = pathinfo($parameters['name'], PATHINFO_FILENAME);
|
|
||||||
$photo = self::getAvatar($uid, $parameters['type'], Proxy::PIXEL_SMALL);
|
if (!empty($parameters['nickname_ext'])) {
|
||||||
} elseif (!empty($parameters['name'])) {
|
$nickname = pathinfo($parameters['nickname_ext'], PATHINFO_FILENAME);
|
||||||
$photoid = pathinfo($parameters['name'], PATHINFO_FILENAME);
|
$user = User::getByNickname($nickname, ['uid']);
|
||||||
|
if (empty($user)) {
|
||||||
|
throw new HTTPException\NotFoundException();
|
||||||
|
}
|
||||||
|
|
||||||
|
$uid = $user['uid'];
|
||||||
|
}
|
||||||
|
|
||||||
|
// User Id Fallback, to remove after version 2021.12
|
||||||
|
if (!empty($parameters['uid_ext'])) {
|
||||||
|
$uid = intval(pathinfo($parameters['uid_ext'], PATHINFO_FILENAME));
|
||||||
|
}
|
||||||
|
|
||||||
|
$photo = self::getAvatar($uid, $parameters['type'], $customsize ?: Proxy::PIXEL_SMALL);
|
||||||
|
} else {
|
||||||
|
$photoid = MPhoto::stripExtension($parameters['name']);
|
||||||
$scale = 0;
|
$scale = 0;
|
||||||
if (substr($photoid, -2, 1) == "-") {
|
if (substr($photoid, -2, 1) == "-") {
|
||||||
$scale = intval(substr($photoid, -1, 1));
|
$scale = intval(substr($photoid, -1, 1));
|
||||||
|
|
|
@ -371,9 +371,13 @@ return [
|
||||||
'/permission/tooltip/{type}/{id:\d+}' => [Module\PermissionTooltip::class, [R::GET]],
|
'/permission/tooltip/{type}/{id:\d+}' => [Module\PermissionTooltip::class, [R::GET]],
|
||||||
|
|
||||||
'/photo' => [
|
'/photo' => [
|
||||||
'/{name}' => [Module\Photo::class, [R::GET]],
|
'/{name}' => [Module\Photo::class, [R::GET]],
|
||||||
'/{type}/{name}' => [Module\Photo::class, [R::GET]],
|
// User Id Fallback, to remove after version 2021.12
|
||||||
'/{type}/{customsize}/{name}' => [Module\Photo::class, [R::GET]],
|
'/{type}/{uid_ext:\d+}' => [Module\Photo::class, [R::GET]],
|
||||||
|
'/{type}/{nickname_ext}' => [Module\Photo::class, [R::GET]],
|
||||||
|
// User Id Fallback, to remove after version 2021.12
|
||||||
|
'/{type}/{customsize}/{uid_ext:\d+}' => [Module\Photo::class, [R::GET]],
|
||||||
|
'/{type}/{customsize}/{nickname_ext}' => [Module\Photo::class, [R::GET]],
|
||||||
],
|
],
|
||||||
|
|
||||||
'/pretheme' => [Module\ThemeDetails::class, [R::GET]],
|
'/pretheme' => [Module\ThemeDetails::class, [R::GET]],
|
||||||
|
|
Loading…
Reference in a new issue