If e.g. the image media type has an alt and title, then on a content type having an image field (I'm using media browser), it selects the image, but the alt & title defined on the media is not inherited or reapplied on the current item. I think it'd be the expected behavior.

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

Anonymous’s picture

Deraynger created an issue. See original summary.

keesje’s picture

This might be caused by a "media_entity" bug: https://www.drupal.org/node/2836423

Anonymous’s picture

@keesje Unfortunately that doesn't solve the problem in my case.

keesje’s picture

ok. since entity_browser is just a widget to select a reference, I doubt that this module is the source of your problem.

keesje’s picture

Try this alternative formatter for your images: https://www.drupal.org/node/2749695#comment-11843530
As I found out the "Thumbnail" formatter is not designed to be used for content display.

slashrsm’s picture

Category: Bug report » Support request
Status: Active » Postponed (maintainer needs more info)
Issue tags: +D8Media

Image media entities can't work with core image field. Could you elaborate a bit on that?

Are you using Lightning? They do something like that, but you have to note that the media entity is not used in that case as the raw image from it is extracted and used in the field.

Anonymous’s picture

Yes, I'm using lightning and using the browser to select the media image.

Anonymous’s picture

Basically this is how I see it, the media has an image. A content type, say page, has an image field too. We add the media image browser to select an image for the page. The image of the media gets selected, but the attributes (Alt and/or Title) used on that image aren't applied, meaning that this data must be set again.

A workaround could be to use the media directly, which would mean rendering the media on the page, so it would require the media to contain all the view modes that the page has, in order to render the various image styles correctly.

Hope that made sense. I still think the media browser module would do so the data set on the media image file would just be copied over to the image of the page.

Anonymous’s picture

Status: Postponed (maintainer needs more info) » Needs work
keesje’s picture

"field_formatter" module could be your friend. more on this: #2749695-11: Thumbnail not updated

balra06’s picture

Hi ,

I am also facing the similar issue in my Drupal Site.

I have an Image Field which uses Entity Browser as the Widget.
Select Image Option in the Image Field opens up the Entity Browser and when i try to upload an image by giving Alt text to it and save it, the alt text is not getting back to the Image field and it expects to enter the alt text and title again

Do we have any solution for this ?

Thanks,
Radha.

leisurman’s picture

Looking for an answer too.

rromore’s picture

StatusFileSize
new1.61 KB

I've dug in a bit and in my case, I believe the issue is because the $entity variable set at FileBrowserWidget.php:246 is of type File, which doesn't hold the alt text information. I've created a patch that looks for the alt text (and title text) on referencing entities. Not sure if this is the best approach but it seems to work. I'm using Drupal 8.6.3, Entity Embed 8.x-1.0-beta2, and Entity Browser 8.x-1.x.

rromore’s picture

StatusFileSize
new1.59 KB

Updated previous patch with some fixes (replacing the hardcoded reference entity key with the variable).

abhijeet.kumar2107’s picture

Issue summary: View changes
StatusFileSize
new283.47 KB

I applied Patch #14 and working fine.
Below steps after applying patch

  • If any image style applied then flush all.
  • Update node then it will update alt and title from media
abhijeet.kumar2107’s picture

Assigned: Unassigned » abhijeet.kumar2107
abhijeet.kumar2107’s picture

Status: Needs work » Needs review
abhijeet.kumar2107’s picture

Assigned: abhijeet.kumar2107 » Unassigned
sourabhutani’s picture

Patch working fine for me. Thanks

visway12’s picture

Version: 8.x-1.x-dev » 8.x-2.2
StatusFileSize
new1.7 KB

I tried the Patch #14 in version 8.x-2.2 and it failed, so re-wrote the patch to support 8.x-2.2 version and it worked for me.

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

samlerner’s picture

The patch stopped applying, and since it's the year 2024, I created an MR and a pull request out of the patch. Looks to be working well, could use a review.

ptkoroma’s picture

Reviwed and patch working fine for me.

samlerner’s picture

Status: Needs review » Reviewed & tested by the community

Moving to RBTC.

berdir’s picture

Status: Reviewed & tested by the community » Needs work

It's quite unclear to me why this there is a use case of mixing direct file selection *and* media referenced, I would assume you'd use either one or the other. I can see it with multiple direct references to files from nodes, but limiting this specifically to media seems strange.

I suggest updating the issue summary with updated instructions on the use case around this and why it should be limited to nodes.

Also, the code should be more careful to verify that the reference is correct and the field exists, with things like revisions and multi-value fields, it might not actually select the media you think it does.

esolano’s picture

StatusFileSize
new1.96 KB

Re-rolling patch to make it compatible with Drupal 10.3

anybody’s picture

Status: Needs work » Postponed (maintainer needs more info)

As of #26

diego sabolo’s picture

I've updated the patch to work with Entity Browser 2.17.0.

The previous patch (#27) was created for an older version and no longer applies cleanly. This updated patch:
- Adapts the code to match the current structure in 2.17.0
- Adds the EntityStorageInterface use statement
- Implements the same functionality: inheriting alt text and title from media entities when using Entity Browser

Tested on:
- Drupal 11.4.5
- Entity Browser 2.17.0

The patch successfully applies and allows alt text/title to be inherited from media entities.