fix(template): repair avatar images in the server-rendered question list - #1583
Open
culfin wants to merge 1 commit into
Open
fix(template): repair avatar images in the server-rendered question list#1583culfin wants to merge 1 commit into
culfin wants to merge 1 commit into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The avatar in
ui/template/question.htmlis built as:.Operator.Avataralready holds the full avatar reference, so prefixing it with/users/yields an address that cannot resolve. Every question in theserver-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:
ui/template/question-detail.htmlsrc="{{.detail.UserInfo.Avatar}}"ui/template/question-detail.htmlsrc="{{.UserInfo.Avatar}}"(twice)ui/template/homepage.htmlsrc="{{.userinfo.Avatar}}"Two further defects sit in the same tag:
alt="shuai"is placeholder text left over from a copied DOM. A screenreader announces it once per avatar. It now carries the display name of the
person who asked.
width="24px"/height="24px"are invalid — HTML dimension attributestake 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.Avataris empty andsrc=""remains— the interface substitutes
default-avatar.svgin that case, the templates donot. That is a separate question and left untouched here to keep this change to
the defect described.
🤖 Generated with Claude Code