1

For accessibility purposes I want to create a view of Media images that do not have any Alt Text.

Creating a view of Media images and also displaying Alt Text is not difficult, as explained is this d.o post Media alt text not available in Views

However I do not know of a way to create a filter of 'Alt Text is NULL' so that a view can be built which only returns images without alt text.

Any suggestions for how could this be accomplished? Ideally this would be a view of media entities so that other filters relating to media can also be used.

2

There is the Filter called Thumbnail (alt) from the Media Category that is for the Alt text.

After you add the Relationship for the Image field the Is empty (NULL) Operator will become available. If the Relationship is not present only the string operators will be listed.

Add the Relationship image from field_media_image and then add the Thumbnail (alt) Filter with the Is empty (NULL) Operator.

It will filter out Media items that have the Alt field available in their structure but not filled in (empty), for example images, as opposed to Files that don't come with Alt fields in their structure.


On the other hand, using the Is less than 1 Operator/value combination can help in situations when you need to filter out different Media types to show the items that don't have the Alt field in their structure at all like File types, while Images with empty alt don't satisfy that condition.

8
  • Thank you for the suggestion @prkos, but unfortunately this is not working out for me. The field certainly works for less than 30, 20, or 5. But I find it does not return images with no alt text based on less than 1. In the d.o link mentioned above, post #9 suggests there is something amiss with Thumbnail Alt. Could this be the reason I am having problems? I am able to reproduce this on simplytes.me - independently of my local environment. – MrPaulDriver May 12 at 17:31
  • I tried it, it is working for me. Are you sure you're doing it inside Media type, and not Content Views type? I'm trying on simplytest.me now – prkos May 12 at 18:17
  • Please try this saved instance on simplytesme stm609cd9ca112ed-dxlwq4fmkdzqaowliqlv5rf8e4g9aeh8.tugboat.qa The link won't last forever but is good for a few hours I think. If it does go dead, I have also exported the view as a pastebin at pastebin.com/vt96byVm – MrPaulDriver May 13 at 8:37
  • My experience is that Thumbnail Alt renders with an image formatter. To expose the alt text it is neccessary to rewrite the field. The filter for shorter than 1 does not appear to work, but greater than 1 does. Not sure what I am doing wrong. – MrPaulDriver May 13 at 8:37
  • Solved it! Thank you for providing the tugboat, I edited your version and got the same result as you! I compared it with my local example and the difference is that in my Media the Alt text is Required (in Media Image Manage Fields settings). After a lightbulb moment I realized my Views example was filtering out File type media, not Image media with empty Alt. So the issue is about the types and I'm guessing how Null is different from zero. My answer was wrong! I'll update it. – prkos May 13 at 14:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.