Skip to content

fix(template): repair avatar images in the server-rendered question list - #1583

Open
culfin wants to merge 1 commit into
apache:mainfrom
Besser-Sehen-Landshut:fix/ssr-avatar-in-question-list
Open

fix(template): repair avatar images in the server-rendered question list#1583
culfin wants to merge 1 commit into
apache:mainfrom
Besser-Sehen-Landshut:fix/ssr-avatar-in-question-list

Conversation

@culfin

@culfin culfin commented Aug 24, 2026

Copy link
Copy Markdown

The avatar in ui/template/question.html is built as:

<img src="{{$.baseURL}}/users/{{.Operator.Avatar}}" width="24px" height="24px"
     class="rounded-circle me-1" alt="shuai" data-processed="true">

.Operator.Avatar already holds the full avatar reference, so prefixing it with
/users/ yields an address that cannot resolve. Every question in the
server-rendered list renders a broken image — ten of them on a default page.
This is also the only template that adds the prefix; the four other places that
show an avatar use the value directly:

file line
ui/template/question-detail.html src="{{.detail.UserInfo.Avatar}}"
ui/template/question-detail.html src="{{.UserInfo.Avatar}}" (twice)
ui/template/homepage.html src="{{.userinfo.Avatar}}"

Two further defects sit in the same tag:

  • alt="shuai" is placeholder text left over from a copied DOM. A screen
    reader announces it once per avatar. It now carries the display name of the
    person who asked.
  • width="24px" / height="24px" are invalid — HTML dimension attributes
    take a number without a unit. Browsers discard them and fall back to the
    intrinsic size of the image, which makes every row of the list taller than the
    interface renders it.

How it was found

Building a site that shows the server-rendered pages to visitors rather than
only to crawlers. All three defects are invisible as long as the React
interface replaces the markup a moment later.

Note

Where a user has no avatar set, .Operator.Avatar is empty and src="" remains
— the interface substitutes default-avatar.svg in that case, the templates do
not. That is a separate question and left untouched here to keep this change to
the defect described.

🤖 Generated with Claude Code

The avatar in question.html is built as `{{$.baseURL}}/users/{{.Operator.Avatar}}`.
`.Operator.Avatar` already holds the full avatar reference, so prefixing it
with `/users/` produces an address that cannot resolve — every question in the
list renders a broken image. The four other templates that show an avatar
(question-detail.html twice, homepage.html) use `{{.UserInfo.Avatar}}`
directly; this is the only place with the prefix.

Two further defects in the same tag:

- `alt="shuai"` is placeholder text left over from a copied DOM. It is read
  out for every avatar on the page, so the alternative text is now the display
  name of the person who asked.
- `width="24px"` and `height="24px"` are invalid: HTML dimension attributes
  take a number without a unit. The browser discards them and falls back to the
  intrinsic size of the image, which makes every row of the list taller than
  intended.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant