Active
Project:
Drupal core
Version:
main
Component:
media system
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
12 Apr 2018 at 14:33 UTC
Updated:
17 Mar 2026 at 14:21 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
seanbI think you can create a relation from the media entity to the source field and fetch the alt text from there since it's a regular entity reference. Could you try that?
Comment #3
chr.fritschNo, the alt and title field is not available.
But following workaround should work:
Comment #4
piotr pakulski#3 @chr.fritsch works for me. Thank you.
Comment #5
andrewmacpherson commentedComment #8
phenaproximaComment #9
andrewmacpherson commented#3 certainly works. I'm using it on a custom admin listing of my own.
Confusingly, there's a views field plugin called "Thumbnail (alt)" but I can't tell how it differs from the "Thumbnail" plugin. Both use the image formatter to output an IMG with an alt attribute.
Comment #10
abhaysaraf commentedComment #11
mrpauldriver commentedBased on the suggestion at #3. How to use this in a contextual filter, to return media images that do not have alt text?
Comment #12
johnpitcairn commentedSimilarly to #11, there is no way to use the image alt or title in a filter. It would be tremendously useful for my editors to be able to filter a view by alt text content (for example, "red").
Comment #13
happy047 commentedReference to #11 and #12, image alt field can be added in both contextual filter and filter criteria and we can filter images based on the alt text provided in the filter criteria. Tried this by creating a view of an article and exposing image alt field in filters. Are you not getting the alt field in your view?
Comment #14
johnpitcairn commentedSorry, I should clarify: there appears to be no way to use the image alt in a "combine fields" filter in a view of media entities, because it isn't available as a field.
Comment #15
happy047 commentedYes, you are right. Image alt cannot be added in combine fields filter in a view. You can alter the view query for a specific project though. For that, you will have to add the image field in combine filter and alter the query in hook_views_query_alter. You can try the following code in your module file:
Although, this is not the best approach, it will work for the mentioned feature. Hope this helps for your specific project. Will update if I find any alternate approach.
Note: In your combine filter, you will need to set your operator as "contains" instead of "equal to"
Comment #20
jwilson3On Drupal 10, I was able to add both a field for the Alt text using the approach in #3, as well as an exposed filter using a grouped dropdown of the "Image (alt)" field using different potential values in the dropdown:
It is indeed odd that "Media image (image:alt)" is available in the filter criteria, but not in the view's field list.
Comment #21
anybodyYeah this is indeed uncool and would be very helpful. I didn't expect that... quite sure we had it in Drupal 7.
Comment #22
mgiffordThis is a bug.
Comment #24
anybodyJust ran into this once again and I think it's really unexpected. Views covers so much, it should also offer these two values!
Comment #25
anybodyPS: One more reason to have this is being able to sort by alt / title in tables. This isn't possible using the workaround.
As filter alt / title are already available!