fix: the avatar and logo URL fallback follows the configured public path

When the thumbnail fails, AvatarURL and OrganisationLogoURL answered
"/" + the blob key, which skips storage.uploads.public_path_prefix and
public_url (a 404 with the WinterCMS layout). They now answer the
original's attach.File.URL.
This commit is contained in:
2026-10-23 21:11:04 +02:00
parent b929ba9f33
commit 9730110d55
5 changed files with 37 additions and 11 deletions

View File

@@ -18,8 +18,9 @@ import (
// AvatarURL returns the display picture URL of user at size pixels, the
// rule the user API payload follows: the thumbnail (size by size, mode
// auto) of the user's avatar attachment when there is one and a file
// bucket is published, the attachment's file path when the thumbnail
// fails (logged), and otherwise the gravatar URL
// bucket is published, the original file's public URL (attach.File.URL,
// following storage.uploads.public_path_prefix and public_url) when the
// thumbnail fails (logged), and otherwise the gravatar URL
// //www.gravatar.com/avatar/{md5 of the email}?s={size}&d=mm. The URL may
// be protocol-relative or relative; a caller that needs an absolute URL
// resolves it. Only a failing database lookup is an error.
@@ -52,7 +53,7 @@ func AvatarURL(ctx context.Context, app *backpack.App, user *models.User, size i
url, err := f.Thumb(ctx, bucket, size, size, "auto")
if err != nil {
pluginLog.Error("golem15.user: avatar thumb", "err", err)
return "/" + attach.BlobKey(f.DiskName), nil
return f.URL(), nil
}
return url, nil
}