fix(avatars): use proper getThumbnailUrl API to eliminate 404 errors
Root cause: Widgets were using getUserAvatar() which returns bare
filenames like 'user-default.png'. These were being used directly as
image src URLs, causing 404 errors like /user-default.png.
Solution: Use getAvatarUrl() dependency which calls getThumbnailUrl()
to convert filenames to proper URLs like /thumbnail?type=persona&file=...
Changes:
- userInfoWidget.js: Use getAvatarUrl('persona', rawAvatar) instead of
raw avatar validation
- sillytavern.js: Simplify updatePersonaAvatar() to trust
getSafeThumbnailUrl() which already calls getThumbnailUrl()
This eliminates 404 errors on initial render and when switching tabs.
This commit is contained in:
@@ -26,6 +26,7 @@ export function registerUserInfoWidget(registry, dependencies) {
|
||||
const {
|
||||
getContext,
|
||||
getUserAvatar,
|
||||
getAvatarUrl,
|
||||
getFallbackAvatar,
|
||||
getExtensionSettings,
|
||||
onStatsChange
|
||||
@@ -50,7 +51,16 @@ export function registerUserInfoWidget(registry, dependencies) {
|
||||
const settings = getExtensionSettings();
|
||||
const context = getContext();
|
||||
const userName = context.name1;
|
||||
const userPortrait = getUserAvatar() || getFallbackAvatar();
|
||||
|
||||
// Get user avatar - use getAvatarUrl to convert filename to proper thumbnail URL
|
||||
let userPortrait = getFallbackAvatar();
|
||||
const rawAvatar = getUserAvatar();
|
||||
|
||||
// Convert raw avatar filename to proper thumbnail URL
|
||||
// getAvatarUrl calls getThumbnailUrl which generates URLs like /thumbnail?type=persona&file=...
|
||||
if (rawAvatar) {
|
||||
userPortrait = getAvatarUrl('persona', rawAvatar);
|
||||
}
|
||||
|
||||
// Merge default config
|
||||
const finalConfig = {
|
||||
|
||||
Reference in New Issue
Block a user