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

@@ -40,8 +40,9 @@ func organisationLogo(ctx context.Context, app *backpack.App, org *models.Organi
// OrganisationLogoURL returns the URL of the organisation's logo at size
// pixels, the way AvatarURL serves a user's picture: the thumbnail (size by
// size, mode auto) of the logo attachment, or the attachment's file path
// when the thumbnail fails (logged). It answers false when the organisation
// size, mode auto) of the logo attachment, or the original file's public
// URL (attach.File.URL, which follows storage.uploads.public_path_prefix and
// public_url) when the thumbnail fails (logged). It answers false when the organisation
// has no logo or no file bucket is published. The URL may be relative; a
// caller that needs an absolute URL resolves it. Only a failing database
// lookup is an error.
@@ -57,7 +58,7 @@ func OrganisationLogoURL(ctx context.Context, app *backpack.App, org *models.Org
url, err := f.Thumb(ctx, bucket, size, size, "auto")
if err != nil {
pluginLog.Error("golem15.user: organisation logo thumb", "err", err)
return "/" + attach.BlobKey(f.DiskName), true, nil
return f.URL(), true, nil
}
return url, true, nil
}