Problem/Motivation

When an author embeds image media in the wysiwyg editor, they can choose to:

  1. accept the default text alternative previously stored with the media entity, or
  2. override the alt text with an instance-specific alt text,

If they accept the default alt text (because it is appropriate for the context) this isn't explicitly recorded; i.e. nothing is stored in the editor markup.

BUT if the default alt text stored with the media entity changes at a later date, then the new alt text propagates to the all existing embed instances which haven't overridden it.

The problem is that the original alt text may have been accepted because is was appropriate to the context, but the new alt text might not be. The upshot is that there may be unintended side effects, where content effectively changes it's meaning.

This is almost in the realm of accidental data loss.

Proposed resolution

When authors embed a media image, and accept the default ALT text from the media entity, explicitly store it in the <drupal-media alt="whatever" markup.

Remaining tasks

TBD.

User interface changes

TBD.

API changes

TBD.

Data model changes

None?

CommentFileSizeAuthor
#8 3084011-8.patch845 bytesphenaproxima

Comments

andrewmacpherson created an issue. See original summary.

andrewmacpherson’s picture

brain dump slack conversation from today. Use this to update the issue summary.

andrewmacpherson 4:11 PM
Related issue, not so major though. Let's say an author embeds an image, and accepts the default alt text from the media entity, because it's appropriate in the context.But later, another editor updates the default text on the media entity.

phenaproxima (he/him) 4:12 PM
I believe it would inherit it, in that case.

andrewmacpherson 4:12 PM
When you accept the default alt text, the <drupal-media> tag doesn't have an alt attribute. So the fact that they have accepted the default isn't really explicit.
Now when the default alt on the media entity is updated, it propagates to all instances which have not explicitly overridden it?
That could be risky. When the author originally accepted the default alt text, it was appropriate to the context. If the default alt stored with the media entity changes, it may no longer be appropriate for the context.
That's kind-of almost in the territory of accidental data loss.

phenaproxima (he/him) 4:16 PM
@wimleers (he/him) Any opinion on this? ^^

andrewmacpherson 4:16 PM
I have a feeling ATAG has something to say about this, will check later.

phenaproxima (he/him) 4:17 PM

@andrewmacpherson That feels like a documentation issue to me, almost. Media is built on entity references; entity references are centralized by their nature.

andrewmacpherson 4:17 PM
A different approach would be to explicitly store the <drupal-media alt>` in all cases, so there text the author accepted survives.

phenaproxima (he/him) 4:17 PM
We are introducing this new pattern here, of a centralized thing that can be decentralized on request.

andrewmacpherson 4:18 PM
but that's at the cost of making it more difficult to propagate changes in the default alt text.

phenaproxima (he/him) 4:18 PM
Exactly.
So basically…which is a better default behavior? (edited) 
It’s not clear.

andrewmacpherson 4:19 PM
Swings and roundabouts, but I think the safer option is to preserve the alt text that the author approved for the embed instance. Less risk of nasty surprises or unintended content changes.

phenaproxima (he/him) 4:20 PM
@andrewmacpherson I think, on a technical level, this would be a very trivial change for us to make. However, we’d need to validate this with UX and the PMs.
Another option would be to make it configurable.
Which would also be a fairly trivial change.

andrewmacpherson 4:22 PM
It may come down to what ATAG says. Will file a separate issue about this. Need to review ATAG again.

phenaproxima (he/him) 4:22 PM
++
Keep me posted!

andrewmacpherson 4:22 PM
Configurable would be an option, but documentation will be important. Warnings on the config page, etc.

phenaproxima (he/him) 4:23 PM
Agreed.

andrewmacpherson’s picture

Priority: Normal » Major

Tempted to say critical, this is almost in the area of data loss.

andrewmacpherson’s picture

Priority: Major » Critical

What the heck, we can triage it down again if needs be.

Must decide on policy for this before marking media library as stable.

DeFr’s picture

Just chiming in, but from an accessibility point of view, I'm not sure storing that alt text all the time is the correct thing to do ; this issue right now focuses on the idea that the alt text may change, but think about it the other way, the embedded image can be changed too, and this will be propagated everywhere.

If you've copied the alt text everywhere and it's no longer appropriate for the new image, then, you'll have to manually go back to all the content embedding that media and re-change the alt text there too.

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

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

phenaproxima’s picture

When authors embed a media image, and accept the default ALT text from the media entity, explicitly store it in the <drupal-media alt="whatever" markup.

This would be quite trivial from an implementation standpoint. So this issue, IMHO, is not primarily technical in nature.

The real problem is the user expectation. What is the right thing to do? As Andrew and I discussed in #2, it's not clear.

Because it is (I think) so easy to do on a technical level, my suggestion is to make this behavior configurable. I'm not sure if it should be globally configurable or specific to the text format configuration, or what the default behavior should be, but this seems like a case where we might want to have it both ways because I agree, this could almost -- almost -- be considered data loss if authors are not expecting it.

At the very least, this should be explicitly documented in our handbook before we downgrade this issue to a less severe priority.

phenaproxima’s picture

StatusFileSize
new845 bytes

Here, for manual testing purposes, is a one-line proof of concept patch. Note that, if our tests are checking that "upstream" changes to alt text get propagated to embeds, it will likely break existing test coverage. (Which is good; that means we have comprehensive tests, and that the current behavior was intentional :)

catch’s picture

2. override the alt text with an instance-specific alt text,

If you do this, can the alt text be identical to the one in the media item? If so I'm not sure we should change the current behaviour at all since we'd be losing the option to just rely on the media entity and there's already a workaround.

phenaproxima’s picture

If you do this, can the alt text be identical to the one in the media item?

Yes, it can.

catch’s picture

Priority: Critical » Major

OK in that case I'm definitely downgrading this from critical to major, but potentially we need to be clearer to end users what the behaviour is.

phenaproxima’s picture

Title: Potential for unintended loss of alt text in embedded image media » The source of alt text in embedded image media is not clear

Re-titling to remove the word "loss", now that @catch has chimed in and does not consider this a data loss.

andrewmacpherson’s picture

How is an unintended content change, which happens elsewhere, not data loss?

The title change de-emphasizes the consequences of an action. The problem is not so much that the source of alt text isn't clear when dealing with an instance where a media entity is used. Rather it's that when dealing with a media entity itself, the consequence of changing the alt text isn't conveyed.

It might not be data loss from the perspective of a database administrator, but it is data loss from the perspective of a content manager.

phenaproxima’s picture

It might not be data loss from the perspective of a database administrator, but it is data loss from the perspective of a content manager.

I agree with this assessment, and that's why this is definitely a major problem that needs to be fixed as soon as possible.

However, I still don't think it's data loss in the normal sense that the term is used in Drupal. As I understand it, when a committer says "data loss", they're referring to loss of explicit user input. This bug is not that. If the user inputs explicit alt text, even if it's the same as the default, that alt text is remembered.

phenaproxima’s picture

Issue tags: +Amsterdam2019

Tagging this important issue to be worked in at DrupalCon Amsterdam.

andrewmacpherson’s picture

I chatted with @phenaproxima about this...

  • It's major, but was still listed as un-triaged on the media_library roadmap. Since we have a feasible proposal for a configurable policy and/or an upgrade path, this issue isn't considered a must-have for #2834729: [META] Roadmap to stabilize Media Library.
  • Instead, we agree it's a must-have before enabling the media library in Standard profile.
  • It could have a big impact on distros, some of which I expect will enable media library before Standard profile does. That's what change records are for.
  • He provided a Google Doc with media library assumptions. I'm going to compare these with the WAI Authoring Tools Accessibilty Guidelines (ATAG) to see if they are harmonious. The ATAG implementation guide has a whole section about "save for re-use" features. Some WCAG criteria are also relevant, notably SC 3.3.4 "Error Prevention (Legal, Financial, Data)" at level AA.

I'll update the media and media_library roadmap issues.

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.

andrewmacpherson’s picture

benjifisher’s picture

One of Drupal's strengths is its structured data.

A practical example of that is that an image can be used in many places, with consistent alt text. But consistent does not mean correct: the same typo may appear consistently everywhere that image is used. With the current behavior, all of those images (potentially) are getting their alt text from the media item. Fix the typo there, and you fix it everywhere.

I do not want to lose that feature unless there is a strong argument in favor of the alternative.

If we want alternatives, then they can be provided by contrib modules. It should be pretty easy to alter the form, add a submit function, and change the way alt text is handled.

volkswagenchick’s picture

Issue tags: +NorthAmerica2021

Adding NorthAmerica2021 tag for visbility.

DrupalCon NA is April 12-16 with a focus on EOOTB on Wednesday, April 14.
Thanks

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.

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.

smustgrave’s picture

Issue tags: +Bug Smash Initiative

This came up as a daily BSI target.

Is the issue here that the alt text is not included in the embed code? Is that really a problem though?

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.