Make WordPress Core

Opened 5 months ago

Last modified 2 months ago

#63838 new defect (bug)

Site logo block should provide a way to specify alt text

Reported by: fab1en's profile Fab1en Owned by:
Milestone: 7.0 Priority: normal
Severity: normal Version: 6.8.2
Component: Media Keywords: needs-test-info has-screenshots
Focuses: accessibility, template Cc:

Description

When using the core site logo block, I can choose an image from the media library, but there is no "alt text" input that appear for normal image block.
If my site logo display a text, I should provide a textual alternative for screen readers.

Site logo block without alt text:
https://pad.coopaname.coop/uploads/6e095822-c7a4-4f33-8351-6d80b358bd0a.png

Image block with alt text :
https://pad.coopaname.coop/uploads/7c28fa67-c33c-439d-aa55-1b2b00f6bfa5.png

Attachments (7)

site-logo-block.png (52.2 KB) - added by Fab1en 5 months ago.
Site logo block
image-block.png (39.2 KB) - added by Fab1en 5 months ago.
Image block
site-logo-block-settings-no-alt-text-field.png (112.2 KB) - added by circlecube 5 months ago.
site-logo-with-no-alt-text-site-title-used.png (679.8 KB) - added by circlecube 5 months ago.
site-logo-media-library-no-alt-text.png (71.7 KB) - added by circlecube 5 months ago.
site-logo-media-library-with-alt-text.png (74.5 KB) - added by circlecube 5 months ago.
site-logo-with-alt-text-from-media-library.png (677.8 KB) - added by circlecube 5 months ago.

Download all attachments as: .zip

Change History (18)

@Fab1en
5 months ago

Site logo block

@Fab1en
5 months ago

Image block

#1 @truptikanzariya
5 months ago

  • Keywords needs-test-info added

#2 @rishabhwp
5 months ago

Hey @Fab1en,

Thanks for reporting this! I tested the Site Logo block and you're spot on about the missing alt text field.

Here's what I found:

1) This should be moved to Gutenberg - The Site Logo block is part of Gutenberg, not WordPress Core, so this issue belongs in the Gutenberg GitHub repo.

2) Alt text does work, but it's hidden - After examining the code, I found that the Site Logo block does use alt text, but it pulls it from the alt_text field of the media attachment in the WordPress Media Library (check site-logo/edit.js https://github.com/WordPress/gutenberg/blob/trunk/packages/block-library/src/site-logo/edit.js#L528). This means that if you set alt text when uploading the logo to the Media Library, it will be used. If alt text is not set, the site title is used as a fallback.

3) Main accessibility concern - If both the Media Library alt text and the site title are empty, then the alt text will be completely empty, which could cause accessibility issues.

#3 @joedolson
5 months ago

The alt text of the site logo should fall back to the site title if an alt text isn't set for the image.

There isn't really much need for a separate alt text insertion; pulling it from the media library is a logical place to get it from, and the fall back to the site title is most commonly what is needed in that location.

Are you seeing an example of a case where the site title fallback isn't triggering?

#5 @Presskopp
5 months ago

another solution would be to set a default like

const { alt_text: alt = "Site Logo", source_url: logoUrl } = mediaItemData ?? {};

#6 @circlecube
5 months ago

  • Keywords has-screenshots added

Tested and reproduced the issue that there is no alt text field for a site logo image in the site editor:

I also confirmed that when no alt text is entered for the image in the media library, the alt text for the site logo image on the front end looks to be the site title:


Then I tested that selecting a media library image does load the alt text for that image if it is entered:


A user may not understand that they need to find the image in the media library and add alt text to update the alt text of the site logo, since it is blank and does not match the existing alt text by default. Furthermore, for consistency, it seems that the alt text should be displayed in the site logo editor block settings, since it is displayed for an image block. This teached users where to expect an alt text field, even though it is also in the media library.

#7 @rishabhwp
5 months ago

I noticed that when both the alt text in the Media Library and the site title are empty, the site's logo renders with an empty alt attribute, which could present accessibility concerns.
Should there be a default, hardcoded fallback alt text (for example, "Site logo") to ensure that there is always some alternative text?

https://i.ibb.co/kVdZGFJg/Screenshot-2025-08-26-at-11-24-55-PM.png

#8 @kimberlynachbur
5 months ago

Based on all the activity in this ticket, it looks like we have two issues:

  1. Should we allow the user to set the alt text in the block settings, rather than just in the media library?
  2. What should the behavior be when there is no alt text set and no site title to fall back on?

The second issue is being discussed here in the issue that @Presskopp linked.

The first issue, which I think is probably what falls under the purview of this ticket, is still an open question. Personally, I agree with @circlecube 's assessment that, for a better user experience, allowing the alt text to be edited from the block settings is the right direction to pursue, especially since the image block's settings already set the precedent that alt text can be set from multiple locations.

#9 @joedolson
5 months ago

  • Focuses template added

In keeping with the discussion in #63548, a good fallback for the "no site title, no alt text" case would be the domain name, using the same logic that's used in the admin bar.

I think that's the only part of this ticket that's actionable here; adding an alt text input to the Site Logo block is something that needs to be done in the Gutenberg repository. This already has an open issue: https://github.com/WordPress/gutenberg/issues/37104.

We can definitely still improve the fallback text, however, and I'll leave this issue open to address that.

This ticket was mentioned in Slack in #accessibility by joedolson. View the logs.


2 months ago

#11 @joedolson
2 months ago

  • Milestone changed from Awaiting Review to 7.0

Adding to 7.0 to improve the fallback condition for no site title, no alt text.

Note: See TracTickets for help on using tickets.