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

Replace featured image text isn't visible. #66005

Closed
2 tasks done
afercia opened this issue Oct 10, 2024 · 3 comments · Fixed by #66936
Closed
2 tasks done

Replace featured image text isn't visible. #66005

afercia opened this issue Oct 10, 2024 · 3 comments · Fixed by #66936
Assignees
Labels
[Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). [Package] Editor /packages/editor [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended

Comments

@afercia
Copy link
Contributor

afercia commented Oct 10, 2024

Description

See related #62743 and #65747

Reported on Trac by Necarie.

I'm using a fresh install of WordPress with no additional themes or plugins installed. I'm using the Twenty Twenty-Four theme and the latest version of Firefox.

I imported an xml file to restore posts from another WordPress. There were media files referenced in it that failed to upload, which was fine as I intended to replace the images manually. When I edited the posts to replace the featured images, the featured images option seemed to be missing.

I eventually figured out the option was there, but I couldn't see it because the text on the buttons was the same color as the background. This only happens when there is a reference to a missing image - once I added a valid image, the button appeared as black text on a light background.

It may not seem like a big deal, but it took me a long time to figure out because I'm not familiar with this version of WordPress or where the button was supposed to be. I hope that by reporting it I can spare someone else the frustration I felt - it seems like something easy to fix.

Step-by-step reproduction instructions

  • Import an XML file with posts that have featured images set.
  • Do not copy over the actual images to the wp-content/uploads directory so that the images are actually missing but the posts meta data still refers to them.
  • Edit a post with a featured image set.
  • Observe the Featured Image UI in the Post summary panel.

Screenshots, screen recording, code snippet

This shows the button where "Replace Image" should be visible, but it isn't.

Image

Environment info

No response

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
@afercia afercia added [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). [Package] Editor /packages/editor [Type] Bug An existing feature does not function as intended labels Oct 10, 2024
@afercia
Copy link
Contributor Author

afercia commented Oct 10, 2024

I can reproduce the same issue in a slightly different case e.g. deleting from the filesystem an image that was already set as featured image. The UI behaves slightly differently but it is still very unclear as it doesn't take into account missing or broken images.

First of all I'd like to point out that browsers behave differently when the path to an image is broken. The different behavior depends on various factors e.g. the presence of an alt text, the size applied to the <img /> element and such.

Basically, when there's no alt text, Chrome tends to display a sort of 'broken image placeholder', while Firefox doesn't. Screenshot:

  • On the left: Chrome
  • On the right: Firefox

Worth noting Necarie reported to use Firefox.

Image

In my test the UI behavior is slightly different because the image placeholder is bigger. I guess because my image was actually already uploaded to the Media Library and I deleted it after it was set. Instead, in the reporter case, the image placeholder is way smaller and appears to be in the 'loading' stage.

Regardless, in both cases the placeholder doesn't show anything:

It's important to note that a missing image was problematic also with the previous featured image UI in WordPress 6.5. Screenshot:

Image

Only the UI in WordPress 6.3 was still clearly operable with a missing image. The Replace and Remove controls where always visible, thus making the UI clearer and always operable. Screenshot:

Image

Proposal

While the featured image UI provides meaningful labeling and description of the image on the placeholder button, the forced empty alt text doesn't seem ideal. I'd like to propose to use the same description of the button for the image alt text so that when an image is missing the alt text would work as intended. Screenshot:

Image

On top of that, I think the Replace and Remove buttons should always be visible as proposed in #62743 and #65747

@afercia
Copy link
Contributor Author

afercia commented Nov 12, 2024

Part of this issue has been addressed in #66189

@afercia afercia self-assigned this Nov 12, 2024
@afercia
Copy link
Contributor Author

afercia commented Nov 12, 2024

I was able to reproduce the originally reported issue by importing an xml file with a post containing a featured image and then skipping the 'Download and import file attachments. Basically, the UI doesn't take into account the case when the attachment ID is saved in the database but there's no media` object containing the image meta data.

In this case, the UI does render the placeholder button but it does not render the image element. The placeholder button is empty:

{ !! featuredImageId && media && (
<img
className="editor-post-featured-image__preview-image"
src={ mediaSourceUrl }
alt={ getImageDescription( media ) }
/>
) }

As such, there is no alt attribute to use to provide some message. The button itself should contain some meaningful message.

Animated GIF to illustrate the UI state when this occurs:

Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). [Package] Editor /packages/editor [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.

1 participant