WordPress.org

Make WordPress Core

Opened 6 months ago

Last modified 6 weeks ago

#38768 new defect (bug)

Custom logo is missing meaningful alt attribute

Reported by: sami.keijonen Owned by:
Milestone: 4.8 Priority: normal
Severity: normal Version:
Component: Themes Keywords: has-patch
Focuses: accessibility Cc:

Description

In 38812 default alt fallbacks was removed to improve accessibility.

Therefore custom logo now have empty alt attribute. Should it have meaningful alt attribute by default for better accessibility?

There is background info in Slack archive.

Attachments (1)

38768.diff (920 bytes) - added by sstoqnov 5 months ago.
Add logo alt attribute

Download all attachments as: .zip

Change History (13)

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


6 months ago

#2 follow-up: @joedolson
6 months ago

I'm inclined to think that the ideal default alt attribute for this case would be the site title. That's likely to be appropriate in most cases - even if it's not a formal match for the text on the alt attribute, it would probably convey the same general information.

#3 @sami.keijonen
6 months ago

Agreed that site title would be nice default alt.

Did some more testing.

  1. Go to the Customizer >> Site Identity.
  2. Click Select logo.
  3. Pick image and write alt text.
  4. Click Select.
  5. Crop image.
  6. Save and Publish.
  7. Cropped image doesn't inherit the alt text that I just wrote in step 3.
  8. If I go back to Media library and add alt text to cropped image, it does show in up in custom logo.

This is probably how it should work but step 7. still feels weird to me. I'd expect that alt text would be in logo image because I just wrote it.

I was testing in Twenty Seventeen.

Also note that if I use image that I don't have to crop, alt text is naturally there.

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


6 months ago

#5 @afercia
6 months ago

  • Milestone changed from Awaiting Review to Future Release
  • Type changed from enhancement to defect (bug)

#6 @afercia
6 months ago

  • Milestone changed from Future Release to 4.8

In 4.6. the alt attribute is just the image filename, and should be improved to have a meaningful value. In 4.7 is going to be an empty alt attribute because the fallback is going to be removed, see [38812]. Either ways, this should be fixed, hopefully during 4.8.

@sstoqnov
5 months ago

Add logo alt attribute

#7 @sstoqnov
5 months ago

  • Keywords has-patch needs-testing added

I agree with you that the site title is a meaningful value for alt attribute, but I think that the user should have control over that value. That's why I think it's better to check if the image has an alt attribute first and then we can add the site title if it's empty.
What do you think? @afercia @sami.keijonen

#8 @nobremarcos
4 months ago

Just tested @sstoqnov path and as he describes it right now there is no checking if the user has added an "Alt Text" to the logo image and it applies the site title to the alt even if the user entered a custom "Alt Text" to it.

#9 @gma992
3 months ago

@nobremarcos

The check in the patch is here:

		if ( empty( $image_alt ) ) {
			$image_alt = get_bloginfo( 'name' );
		}

I've just tested it and works fine when adding a new logo.

If the alt field is empty, is populated automatically with the site title, otherwise is populated with the custom alt text added into the field. Mind to clarify the steps to reproduce why is not working on your end? Maybe I misunderstood the issue you're seeing?

On the other hand, as @sami.keijonen pointed out, when we crop the image, it does not grab the customized alt text, but populates it by an empty alt text by default or with the site title after being patched.

This is the normal behavior thought (but not the expected one) as when we crop the logo, we're creating a new image on the media gallery, and that new image has no alt text yet.

#10 in reply to: ↑ 2 @LiamMcArthur
3 months ago

I agree. I personally think it's overkill to have another input box for the user to specify a custom alt tag for their logo. I think the site title (or even tagline, if a site title isn't set) should suffice.

Replying to joedolson:

I'm inclined to think that the ideal default alt attribute for this case would be the site title. That's likely to be appropriate in most cases - even if it's not a formal match for the text on the alt attribute, it would probably convey the same general information.

#11 @jjcomack
6 weeks ago

  • Keywords needs-testing removed

Tested this patch by going through the following steps:

  1. Uploaded an image to use as a logo (700px x 700px) and applied an alt-tag.
  2. Was prompted to crop said image, which I did, resulting in the alt-tag changing to the site title.
  3. Uploaded a different image (250px x 250px) and applied an alt-tag.
  4. Was given the option to skip cropping, which I did. Original alt-tag remains.

Clearly the issue where the alt-tag gets removed post-cropping (and thus replaced thanks to this patch) needs to be addressed as this leads to inconsistent behavior in the user experience. Will probably be best to create a new issue for this.

#12 @sstoqnov
6 weeks ago

@jjcomack Thanks for testing.
I agree with you that the cropped image should keep the main image attributes, because rarely you will have cropped images with different alt attributes than the main image. If you still need different attribute, you can change it from editor.

Actually there is a ticket for this issue already and I will try to provide a patch when I have some more free time #37750

Note: See TracTickets for help on using tickets.