Add hash to image url to force browser to update profile when changed

Closes #4241
This commit is contained in:
Rafael de Camargo 2019-08-26 01:59:53 -03:00 committed by Frédéric Guillot
parent 8b2d46ed5d
commit 4d07628054
2 changed files with 2 additions and 2 deletions

View File

@ -23,7 +23,7 @@ class AvatarFileProvider extends Base implements AvatarProviderInterface
*/
public function render(array $user, $size)
{
$url = $this->helper->url->href('AvatarFileController', 'image', array('user_id' => $user['id'], 'size' => $size));
$url = $this->helper->url->href('AvatarFileController', 'image', array('user_id' => $user['id'], 'hash' => md5($user['avatar_path']), 'size' => $size));
$title = $this->helper->text->e($user['name'] ?: $user['username']);
return '<img src="' . $url . '" alt="' . $title . '" title="' . $title . '">';
}

View File

@ -29,7 +29,7 @@ class UserMentionFormatterTest extends Base
$expected = array(
array(
'value' => 'someone',
'html' => '<div class="avatar avatar-20 avatar-inline"><img src="?controller=AvatarFileController&amp;action=image&amp;user_id=1&amp;size=20" alt="Someone" title="Someone"></div> someone <small>Someone</small>',
'html' => '<div class="avatar avatar-20 avatar-inline"><img src="?controller=AvatarFileController&amp;action=image&amp;user_id=1&amp;hash=5acc03af0274414544b9615fb223d925&amp;size=20" alt="Someone" title="Someone"></div> someone <small>Someone</small>',
),
array(
'value' => 'somebody',