Skip to content

Fix: Add missing alt text to avatar images (#12707)#12721

Merged
lokesh merged 3 commits into
internetarchive:masterfrom
shaiksahilrizwan:12707/fix/avatar-alt-text
May 15, 2026
Merged

Fix: Add missing alt text to avatar images (#12707)#12721
lokesh merged 3 commits into
internetarchive:masterfrom
shaiksahilrizwan:12707/fix/avatar-alt-text

Conversation

@shaiksahilrizwan
Copy link
Copy Markdown
Contributor

Closes #
Closes #12707

[fix] Adds missing alt text to avatar images on account/bookshelf pages to improve accessibility and resolve WCAG validation errors.

Technical

As discussed in the issue comments, I applied two different accessibility treatments based on the HTML context:

  1. account/view.html: The avatar image is the only content inside its <a> tag. To prevent an "Empty Link" / missing alt attribute error, I added a descriptive alt attribute (alt="$mb.username").
  2. account/follows.html: The avatar image is adjacent to the username text inside the exact same link. To prevent redundant screen reader announcements (reading the username twice), I marked the image as decorative by adding an empty alt attribute (alt=""). This answers Pam's question from the issue thread.

Testing

  1. Navigate to a user's bookshelf page (e.g., http://localhost:8080/people/openlibrary/books).
  2. Inspect the avatar image next to the username at the top of the page. Verify it has alt="[username]".
  3. Run the WAVE accessibility tool and confirm the missing alt text error is gone.
  4. Navigate to a user's following/followers page (e.g., http://localhost:8080/people/openlibrary/following).
  5. Inspect an avatar in the list and verify it has alt="".

Screenshot

works fine and removes the violation:
image

Stakeholders

@lokesh

Copilot AI review requested due to automatic review settings May 12, 2026 02:52
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds missing alt attributes to profile avatar <img> elements in account templates to address WCAG/WAVE accessibility violations on bookshelf and follows pages.

Changes:

  • account/view.html: Adds alt="$mb.username" to the avatar image used as the sole content of an <a> (avoids an “empty link” / missing alt issue).
  • account/follows.html: Adds alt="" to avatar images when the username text is already present in the same link (treats the image as decorative to avoid redundant announcements).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
openlibrary/templates/account/view.html Adds meaningful alt text to the linked avatar image in the account breadcrumb/header.
openlibrary/templates/account/follows.html Marks follower/following avatar images as decorative via empty alt where adjacent link text already provides the label.

@mekarpeles
Copy link
Copy Markdown
Member

Thanks for the contribution!

@lokesh is assigned to this PR and currently has:

  • 0 open PR(s) of equal or higher priority to review first
PR triage checklist (maintainers / Pam)
  • PR description — not empty; explains what the change does and how to verify it
  • References an issue — PR body contains a #NNN reference
    • Linked issue is triaged — has a Priority: * label (not just Needs: Triage)
    • Linked issue is assigned — has at least one assignee
  • Commit history clean — no WIP/fixup/conflict noise; commit messages are meaningful
  • CI passing — no failing check-runs
  • Test cases present — if the change touches substantive logic, test coverage exists or is explained
  • Proof of testing — PR body includes a description of what was tested, a screenshot, or a video

Note

This comment was automatically generated by Pam, Open Library's Project AI Manager, on behalf of @mekarpeles. Pam is designed to provide status visibility, perform basic project management functions and relevant codebase research, and provide actionable feedback so contributors aren't left waiting.

$# Only show breadcrumbs when we're not on mybooks
<div class="account-breadcrumb">
<a href="$mb.user.key" class="username-avatar"><img src="$(mb.user.key)/avatar" class="account-avatar"></a>
<a href="$mb.user.key" class="username-avatar"><img src="$(mb.user.key)/avatar" class="account-avatar" alt="$mb.username"></a>
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The avatar is decorative here. The name is already accessible in the link. Let's avoid a duplicate announcement by doing an empty alt="" here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lokesh So, I tried that approach as well before using wave tool this is the case:
image
so adding alt with username :
image
getting a redundent text alert, if using alt="" the case is again error missing alternative text :
image

Update account avatar image alt attribute to be empty as avatar is decorative
Copy link
Copy Markdown

@accesslint accesslint Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found 1 issue across 1 rule.

Comment thread openlibrary/templates/account/view.html Outdated
$# Only show breadcrumbs when we're not on mybooks
<div class="account-breadcrumb">
<a href="$mb.user.key" class="username-avatar"><img src="$(mb.user.key)/avatar" class="account-avatar"></a>
<a href="$mb.user.key" class="username-avatar"><img src="$(mb.user.key)/avatar" class="account-avatar" alt=""></a>
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WCAG 2.4.4, WCAG 4.1.2: Link has no discernible text.

Links must have discernible text via content, aria-label, or aria-labelledby.

Details

href: $mb.user.key
Parent text: $mb.username ›

Screen reader users need to know where a link goes. Add descriptive text content, aria-label, or use aria-labelledby. For image links, ensure the image has alt text describing the link destination. Avoid generic text like 'click here' or 'read more'—link text should make sense out of context.

@shaiksahilrizwan shaiksahilrizwan requested a review from lokesh May 13, 2026 03:31
@shaiksahilrizwan
Copy link
Copy Markdown
Contributor Author

@lokesh can you please review this once

@github-actions github-actions Bot added the Needs: Response Issues which require feedback from lead label May 14, 2026
Copy link
Copy Markdown
Collaborator

@lokesh lokesh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggesting one tweak — see inline comment.

Comment thread openlibrary/templates/account/view.html Outdated
Copy link
Copy Markdown
Collaborator

@lokesh lokesh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@lokesh lokesh merged commit 08ae234 into internetarchive:master May 15, 2026
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs: Response Issues which require feedback from lead

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Accessibility: Profile avatar image missing alt text on reading log/bookshelf pages

4 participants