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

Modifying Alt Text replaces Media "Name" #1591

Open
elizoller opened this issue Aug 27, 2020 · 11 comments
Open

Modifying Alt Text replaces Media "Name" #1591

elizoller opened this issue Aug 27, 2020 · 11 comments
Assignees
Labels
Type: bug identifies a problem in the software with clear steps to reproduce

Comments

@elizoller
Copy link
Member

When I edit an existing media item and change the value in the "Alt Text" field and save the media, the "Name" of that media gets rewritten as the filename. If I don't change the "Alt Text" when updating a media, the "Name" field persists as whatever I had previously entered. I believe this is related to: Islandora/islandora@d5f88d6
This is undesirable behavior in my opinion because we would like a custom "Name" for a media to persist, but please let me know if this is working as designed.

@mjordan mjordan self-assigned this Aug 27, 2020
@mjordan
Copy link
Contributor

mjordan commented Aug 27, 2020

@elizoller thanks for finding this. I've assigned it to myself.

@mjordan
Copy link
Contributor

mjordan commented Aug 28, 2020

This is unrelated to Islandora/islandora@d5f88d6, it happens on the release VM too. I'll continue to investigate.

@elizoller
Copy link
Member Author

Ah ok. Just a coincidence I noticed right after I pulled down. Thanks

@mjordan
Copy link
Contributor

mjordan commented Sep 10, 2020

I can't figure out what's causing this. The alt text widget in this case is defined in core/modules/image/src/Plugin/Field/FieldWidget/ImageWidget.php, even though other alt text widgets are defined elsewhere:

vagrant@islandora8:/var/www/html/drupal/web$ grep -r "This is important for accessibility."
core/modules/editor/src/Form/EditorImageDialog.php:      '#description' => $this->t('Short description of the image used by screen readers and displayed when the image is not loaded. This is important for accessibility.'),
core/modules/image/src/Plugin/Field/FieldType/ImageItem.php:      '#description' => t('Short description of the image used by screen readers and displayed when the image is not loaded. This is important for accessibility.'),
core/modules/image/src/Plugin/Field/FieldWidget/ImageWidget.php:      '#description' => t('Short description of the image used by screen readers and displayed when the image is not loaded. This is important for accessibility.'),
core/modules/media/src/Form/EditorMediaDialog.php:        '#description' => $this->t('Short description of the image used by screen readers and displayed when the image is not loaded. This is important for accessibility.'),

But I can't figure out why the one in core/modules/image/src/Plugin/Field/FieldWidget/ImageWidget.php would be interfering with the Name value in our Image field.

@jordandukart
Copy link
Member

Will dig into this today @mjordan and @elizoller sorry for not seeing this issue before now.

@jordandukart
Copy link
Member

So this isn't our code related AFAICT. That is, media provides ways to map properties out of the file proper to fields:

Screenshot_2020-09-10 Edit Image Drupal

Was able to reproduce this on a vanilla Drupal box without Islandora present by doing the following:

  • Modify the image media type to display the Name field
  • Create a image media entity
  • Upload an image
  • Give it an alt text/name value
  • Save
  • Return and edit the alt text to be something different
  • Save
  • Notice the Name field was overwritten.

Setting the Name field to be skipped in the mapping resolves this.

I guess Islandora could modify what default config settings are being rolled but if this could be changed on a per install basis.

@rosiel
Copy link
Member

rosiel commented Sep 11, 2020

Wait, "Name" and "alt text" appear as two different fields on the Media. If "Alt text" were mapped to "main" then I would expect the behaviour that you're describing.

Are you saying that in drupal, when "Name" is mapped to "Name", changing the alt text causes the Name, as stored in the database, to be overwritten?

@jordandukart
Copy link
Member

As in if you had changed the Name to be something else like Rosie's cool file and saved it initially it'd hit the database with that. On an edit if you changed any value it'd default the Name back to the filename given that mapping.

@kayakr
Copy link
Contributor

kayakr commented Apr 12, 2021

I've just run into this issue also, and it's present on current Islandora sandbox.
https://www.drupal.org/project/drupal/issues/3157183 is relevant as is https://www.drupal.org/project/drupal/issues/3192059

@kayakr
Copy link
Contributor

kayakr commented Apr 12, 2021

The patch from https://www.drupal.org/project/drupal/issues/3192059#comment-13989559 applies to Drupal 8.9.13 ok and resolves this issue.

@kstapelfeldt kstapelfeldt added Type: bug identifies a problem in the software with clear steps to reproduce and removed bug labels Sep 25, 2021
@kstapelfeldt
Copy link
Member

@elizoller is this fixed? As per the associated drupal.org issues final comment "I'm moving this back to 9.1.x and marking as Fixed" - We are assuming this is resolved in 9.1.x with earlier Drupal users having to apply the patch linked in the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: bug identifies a problem in the software with clear steps to reproduce
Projects
Development

No branches or pull requests

6 participants