Problem/Motivation

The Media alts view shipped with this module includes an "Alt attribute" grouped filter that lets editors find media items with empty or non-empty alt text. The filter uses the standard Drupal Views string plugin with the empty / not empty operators.

Those operators translate to IS NULL / IS NOT NULL SQL conditions. However, when an image field is saved with a blank alt value, Drupal stores an empty string ("") in the database column rather than NULL. This means:

  • The "Is empty" filter option silently misses every media item whose alt is "" instead of NULL.
  • The "Is not empty" filter option incorrectly includes those same items, reporting them as having alt text when they do not.

The result is that the view cannot be trusted to surface all images that are missing accessible alt text, which defeats the accessibility-audit purpose of the view.

Steps to reproduce

  1. Install the module on a Drupal 10/11 site with at least one Image or Media image bundle.
  2. Upload an image and intentionally leave the alt text field blank. Save the media entity.
  3. Go to Admin > Content > Media alts (the view provided by this module).
  4. Filter by Alt attribute Is empty.
  5. Observe that the media item saved with a blank alt ("") does not appear in the results.
  6. Filter by Alt attribute > Is not empty.
  7. Observe that the same item does appear, incorrectly suggesting it has an alt value.

Proposed resolution

Replace the two grouped filter options with custom filter classes (extending StringFilter or FilterPluginBase) that produce compound SQL conditions:

  • "Is empty" should generate: field IS NULL OR field = ''
  • "Is not empty" should generate: field IS NOT NULL AND field <> ''
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

eduardo morales alberti’s picture

Status: Active » Needs review

Ready to review

alejandro cabarcos’s picture

Thanks Edu!

Tested and merged into 1.0.x

alejandro cabarcos’s picture

Status: Needs review » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.