Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Media & text block: The Alt text for the featured image is not working correctly #60023

Closed
carolinan opened this issue Mar 20, 2024 · 10 comments · Fixed by #60496
Closed

Media & text block: The Alt text for the featured image is not working correctly #60023

carolinan opened this issue Mar 20, 2024 · 10 comments · Fixed by #60496
Assignees
Labels
[Block] Media & Text Affects the Media & Text Block [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended

Comments

@carolinan
Copy link
Contributor

Description

When the Media & text block uses a featured image, the alt text is:

  1. Pre-populated with the alt text from the media library, and can not be deleted or replaced from the alt text input field in the editor.
  2. Not present on the front.

Step-by-step reproduction instructions

With Gutenberg active:
Create a new post and assign a featured image that has an alt text in the media library.
Add a Media & text block and select the option "Use Featured image".
Try to change the text in the block settings panel.
Save and reload the post.
Confirm that the alt text does not include the changes you made.

View the source of the block on the front of the site and confirm that there is no alt text output.

Screenshots, screen recording, code snippet

No response

Environment info

Gutenberg current trunk.

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

@carolinan carolinan added the [Type] Bug An existing feature does not function as intended label Mar 20, 2024
@carolinan carolinan self-assigned this Mar 20, 2024
@carolinan
Copy link
Contributor Author

carolinan commented Mar 20, 2024

@draganescu Hi, I am pinging you to ask for your continued help with this featured image feature.

I have not been able to fully solve this issue.

I can solve it partially by not using the alt text from the media library for the featured image. But then there are inconsistencies because it does not match how the alt text works for regular images.
I made a draft PR here, it shows what I had to change, but I don't think it should be merged.

@carolinan carolinan added the [Block] Media & Text Affects the Media & Text Block label Mar 20, 2024
@draganescu
Copy link
Contributor

Is this something that plagues the other "use featured image" enabled blocks (like cover)? Does the featured image block work?

@carolinan
Copy link
Contributor Author

Cover and featured image blocks do not have alt text options.

@t-hamano
Copy link
Contributor

t-hamano commented Apr 4, 2024

I confirmed the approach you are trying in #60029.

One thing to consider is that this block may be used inside a template or query loop block. For example, when used in a Single template, I don't think the alt text should be editable because the featured image changes dynamically depending on the post. Also, if it is inside a Query Loop block, I think the alt will be updated all at once.

Not present on the front.

In my opinion, it's better to just solve this problem first. In other words, similar to the Featured Image block, if "Use featured image" is enabled, the alt text control will be hidden, and the front end will always output the alt attribute of the media itself.

After that, we can explore approaches to make the alt text editable from a broader perspective, that is, the three blocks of the Featured Image block, Cover block, and Media & Text block, taking templates and query loop into consideration.

@draganescu
Copy link
Contributor

if "Use featured image" is enabled, the alt text control will be hidden, and the front end will always output the alt attribute of the media itself.

This, I find this to be a predictable and good enough path.

@carolinan
Copy link
Contributor Author

Yes, it is not great, but I had the same thought.

@alexstine
Copy link
Contributor

Part of me wonders if we should fix the root problem here vs. adding a band-aid. Lots of work involved?

@t-hamano
Copy link
Contributor

t-hamano commented Apr 8, 2024

Lots of work involved?

I think so. Because the featured image changes dynamically depending on the context, Alt text data cannot be stored in the block markup or the comment delimiter. I think one approach would probably be to save it as a post meta with the definition "Alt text of the featured image in this post". I think this requires a lot of experimentation and verification.

@alexstine
Copy link
Contributor

CC: @joedolson for any final feedback.

@carolinan
Copy link
Contributor Author

carolinan commented Apr 9, 2024

There is one more known issue that will need to be fixed besides removing the alt text option and fixing the missing link.
When the featured image is linked and there is no alt text, there is no link text. I have not opened the PR for that yet but I plan to.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Media & Text Affects the Media & Text Block [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants