Media thumbnail image title is not filled from source entity

Created on 29 July 2021, over 3 years ago
Updated 12 August 2024, 6 months ago

Problem/Motivation

While tried to render a referenced image media field I noticed that the source code does not contain the title attribute on the image tag even if we require the title to be filled up on media creation.
After digging in the code I've found out that the Thumbnail formatter using the `$media->get('thumbnail')->first()` code to fetch the image, and not the original field. After further investigation, I've found that the Drupal\media\Plugin\media\Source\Image::getMetadata place just the alt text is set, while the title is totally missing.

Steps to reproduce

1. Create media with an image field (require alt and title).
2. Create a content type and attach this previously created media as a reference field.
3. In the same content type, set the field formatter to Thumbnail.
4. Create content with this content type.
5. View the source of it, and you will see there's no title just alt.

Proposed resolution

Needs to be fixed so the title attribute is rendered.

Remaining tasks

- Create a hook_update (?) to update all the existing image entity.
- Test.

User interface changes

-

API changes

-

Data model changes

-

Release notes snippet

-

πŸ› Bug report
Status

Active

Version

11.0 πŸ”₯

Component
MediaΒ  β†’

Last updated about 10 hours ago

Created by

πŸ‡§πŸ‡ͺBelgium golddragon007

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024