Bust avatar/banner cache so new image shows on all pages

After my previous fix the upload succeeds, but the avatar path is always
.../profile/avatar.<ext>, so its media URL never changes. Pages other than the
channel (which cache-busts with ?t=) kept serving the browser-cached OLD image
— the user "still saw the old avatar" on /videos.

- avatar_url / banner_url accessors append ?v=<updated_at timestamp>.
- updateAvatar / updateBanner now bump updated_at explicitly (the path is
  unchanged, so Eloquent wouldn't otherwise touch it), changing ?v so every
  page fetches the new image.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
This commit is contained in:
ghassanandClaude Opus 4.8 committed 2026-07-29 00:39:47 +03:00
1 parent 5d4d21dcec
commit 8ea63a6720
2 files changed
+15 -4

No files matched your search

+10 -2
View File
@@ -565,7 +565,11 @@ class UserController extends Controller
rename($tempPath, $destPath);
}
$user->update(['avatar' => $relPath]);
// Bump updated_at even when $relPath is unchanged (avatar.png -> avatar.png)
// so avatar_url's ?v cache-buster changes and every page shows the new image.
$user->avatar = $relPath;
$user->updated_at = now();
$user->save();
if ($nas->isEnabled() && file_exists($destPath)) {
$nas->syncAvatar($user, $destPath);
@@ -602,7 +606,11 @@ class UserController extends Controller
rename($tempPath, $destPath);
}
$user->update(['banner' => $relPath]);
// Bump updated_at even when $relPath is unchanged so banner_url's ?v buster
// changes and the new banner shows everywhere (see updateAvatar).
$user->banner = $relPath;
$user->updated_at = now();
$user->save();
if ($nas->isEnabled() && file_exists($destPath)) {
$nas->syncCover($user, $destPath);