Problem/Motivation

During assistive tech walkthroughs, we discovered that it is cognitively confusing to sighted users, and also confusing to screenreader users, that the alt text is placed into the field in a way that makes it appear to be merely placeholder text.

This occurs when the media embed WYSIWYG is used to add an existing image. The existing image's alt text is present as a placeholder, but should instead be the input's actual value.

This interaction can be viewed on the video recording of the September 29, 2019 walkthrough of Media Library at around minute 47.

Proposed resolution

Change it so that the alt text is pre-filled in as regular input, not as placeholder text.

Remaining tasks

  • Adjust and test

User interface changes

Changes the alt text from placeholder to default.

API changes

None anticipated.

Data model changes

None anticipated.

Release notes snippet

TBD

Issue fork drupal-3087535

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

rainbreaw created an issue. See original summary.

phenaproxima’s picture

phenaproxima’s picture

xjm’s picture

Priority: Normal » Major
bnjmnm’s picture

Title: Make the alt text appear as normal entered text rather than placeholder text when adding a pre-existing image using the media library modal » In WYSIWYG embed modal for existing images, the alt text field should have a default value instead of placeholder text
Issue summary: View changes
bnjmnm’s picture

Status: Active » Needs review
StatusFileSize
new2.11 KB

Removed the placeholder attribute and #default_value is used to populate the field based on default or overridden alt text.

Status: Needs review » Needs work

The last submitted patch, 6: 3087535-6.patch, failed testing. View results

bnjmnm’s picture

Status: Needs work » Needs review
StatusFileSize
new898 bytes
new2.62 KB

Fixed tests

seanb’s picture

The patch looks good to me, relatively simple change. I think it would be good to get an a11y maintainer to officially sign off on this, but as far as I can tell this is RTBC. Thanks!

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

tanubansal’s picture

Tested #8, works for me as well
RTBC + 1

abhijith s’s picture

Patch #8 can't be applied.Needs reroll.

Checking patch core/modules/media/src/Form/EditorMediaDialog.php...
Checking patch core/modules/media/tests/src/FunctionalJavascript/CKEditorIntegrationTest.php...
error: while searching for:
    $this->openMetadataDialogWithKeyPress(static::RETURN_KEY);
    // Assert that the placeholder is set to the value of the media field's
    // alt text.
    $assert_session->elementAttributeContains('named', ['field', 'attributes[alt]'], 'placeholder', 'default alt');

    // Fill in the alt field, submit and return to CKEditor.
    $who_is_zartan = 'Zartan is the leader of the Dreadnoks.';

error: patch failed: core/modules/media/tests/src/FunctionalJavascript/CKEditorIntegrationTest.php:659
error: core/modules/media/tests/src/FunctionalJavascript/CKEditorIntegrationTest.php: patch does not apply
abhijith s’s picture

StatusFileSize
new2.55 KB

Rerolled patch #8.

santhosh-kumar-rengasamy’s picture

StatusFileSize
new39.79 KB
new71.76 KB
new214.48 KB

Tested the patch in #14, applied smoothly and working fine.
Thanks for the patch.

filmfactory made their first commit to this issue’s fork.

andrewmacpherson’s picture

seanb’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -Needs accessibility review

Thanks @andrewmacpherson, I think we now have all we need to get this in.

catch’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs usability review

If no alternative text is provided, then the existing alt text for the image will be used. If we always provide a default value, then a user has to explicitly remove the alternative text for to get that behaviour.

The current behaviour is confusing, but this patch is dealing with that by essentially hiding how the widget actually works as far as I can tell.

This feels like a duplicate of #3084011: The source of alt text in embedded image media is not clear, but marking needs work rather than duplicate so there's a chance to discuss more.

dyannenova’s picture

StatusFileSize
new20.45 KB

This is roughly what I was suggesting on the Drupal UX call.

The text field would display the store media alt text and be disabled until the Override box is checked. If the user unchecks the Override box then the text reverts to the stored Media alt text and is again disabled.

wireframe of proposed alternative text behavior

jhodgdon’s picture

We discussed this in the Usability meeting today #3198188: Drupal Usability Meeting 2021-02-19. Here is I hope an accurate summary of what we talked about doing (the proposal in the previous comment is another idea of how to make this more understandable):

a) We're talking about a dialog that you get when you click "Edit media" after embedding a media item in content. The dialog has a field that is currently called "Alternate text", and the ability to align the image (left/right/center) and add a caption. The field in question in this issue is the alternate text field.

What this field actually does:
- If its value is empty, the alt text shown comes from the underlying image.
- If its value is not empty, the value overrides the alt text from the underlying image.

b) Without this patch, when you open this dialog, if the value is empty, you'll see placeholder text showing the underlying image value. And if the value is not empty, you'll see the value. If you then delete the value, you'll see the placeholder text. This is confusing because the user doesn't know where this placeholder is coming from, and there is nothing in the UI telling them what is happening.

c) With this patch, the behavior is that if the value was empty before opening the dialog, the underlying image's value is put in as the value, and there is not a placeholder. This is bad for a few reasons:
- The user still doesn't understand what is happening.
- If the user opened the dialog in order to change alignment, for example, and doesn't touch the alt text field, and it was previously an empty value, after saving they have now saved an override. So, they do nothing in the field, and the database-saved value changes.

So.... What this issue really needs is a better UI that explains what is going on. The suggestion we came up with:
1. Above the Alternate text field that is currently in the dialog, display something that looks like this:

Current alternate text
(Show the value from the underlying image here)

2. Change the label of the Alternate text field to say Alternate text override (because that is what it actually is)

3. Don't have a placeholder and don't grab the value from the underlying image. If it's empty, leave the field empty.

4. Update the description of the Alternate text override field (and/or the Current alternate text value display?) to explain what is going on. Maybe something like:
Override the alternate text from _____ (where is it actually coming from?). [and then an explanation of what alternate text is, which is currently "Short description of the image used by screen readers and displayed when the image is not loaded. This is important for accessibility."]

We didn't come up with the details of (4) in our meeting.

benjifisher’s picture

Issue tags: -Needs usability review

I am removing the tag for usability review. See #21: we discussed this issue at the Usability meeting on 2021-02-19.

My personal vote is for the suggestion in #21 rather than the one in #20. I generally do not like the pattern of a checkbox that enables a text field: all you need is the text field, which you can leave empty (like leaving the checkbox un-checked) or not (like checking the box). And, as explained in #21, we still want to clarify where the default text comes from.

I strongly oppose any solution that removes the option of using the value from the media item, which may be updated. One key feature of image media (compared to image file fields) is that they are designed to be reusable. If an image is used in many places on the site, and I need to fix a typo in the alt text, then I want the option of fixing them all at once.

For sites that do not want that behavior, it would be nice to have an easy way to save the default text as the override text. With the suggestion in #21, an editor could copy and paste the default text. (That is not an option with placeholder text, the current implementation.) A contrib module could provide a more conventient option.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

timohuisman’s picture

StatusFileSize
new2.52 KB
new1.23 KB

Rerolled #14 against 9.5.x and 10.1.x. It seems to be that the tests in 10.1.x are removed, but I'm not totally sure about that, so maybe someone else can verify that.

I keep the issue at needs work because of #22.

mgifford’s picture

Issue tags: +wcag111

Tied to WCAG 1.1.1

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

charles belov’s picture

For maximum usability, I would suggest the following.

  • Show the existing media library default alternative text outside and preceding the field, so that someone who is typing new text in the field can refer to the existing text while they are typing the new text. This reduces cognitive load and also makes it easier for the content editor to:
    • decide whether they want to keep the default alt text or write new alt text.
    • revert any edits while still having the original available to them.
    • do a quality comparison between the default text and the new text.
  • Ensure that the displayed existing text is copy-and-paste-able.
  • Leave the placeholder text as is.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.