Skip to content

Skip 1x1 images (tracking pixels) with empty alt in img_alt_empty_check #1660

@pattonwebz

Description

@pattonwebz

Please give us a description of what happened.

Currently, src/pageScanner/checks/img-alt-empty-check.js skips some hard-coded image URLs (like known smileys and specific tracking pixels), but does not automatically skip images that are exactly 1x1 in size. True tracking pixels with width="1" and height="1" (from any src or base64) should also be ignored by the rule if they have an empty alt attribute, to avoid false positives for WCAG 1.1.1.

Please describe what you expected to happen and why.

The accessibility check should automatically skip (ignore) all img elements with empty alt attributes if their width and height are both exactly 1 (matching tracking pixel conventions), regardless of the src path. This aligns with standard practice—1x1 tracking pixels are not meaningful visual content.

How can we reproduce this behavior?

  1. Create or test a post with the following image markup:

    <img src="tracking.gif" alt="" width="1" height="1">
  2. Run Accessibility Checker: it reports this as a failure, but it should be SKIPPED.

  3. Try with a non-tracker 1x1 image (other src):

    <img src="https://example.com/whatever.png" alt="" width="1" height="1">

    It also fails (should be skipped).

  4. Try with a slightly larger image:

    <img src="tiny.png" alt="" width="2" height="1">

    This should continue to fail (not be skipped) as it’s not a 1x1 tracking pixel.

Technical info

  • WordPress version: (any)
  • Accessibility Checker version: (any)
  • Editor(s): any
  • Browser(s): any

Please reference these required tests in tests/jest/rules/imgAltEmpty.test.js

  • <img src="track.gif" alt="" width="1" height="1"> → shouldPass: true
  • <img src="https://example.com/whatever.png" alt="" width="1" height="1"> → shouldPass: true
  • <img src="tiny.png" alt="" width="2" height="1"> → shouldPass: false
  • (optional) <img src="maybe-tracker.gif" alt=""> → shouldPass: false

Strongly recommend adding/expanding tests in tests/jest/rules/imgAltEmpty.test.js to verify this edge case and prevent regression!


Labels: bug, a11y

Metadata

Metadata

Labels

a11yAccessibility ImprovementbugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions