Skip to content

Commit

Permalink
feat: adds an a11y warning when a image is missing alt-text (#465)
Browse files Browse the repository at this point in the history
* feat: adds an a11y warning when a image is missing alt-text

* fix: remove the need for a class.

---------

Co-authored-by: Sebastian Thulin <sebastian.thulin@helsingborg.se>
  • Loading branch information
sebastianthulin and Sebastian Thulin authored Oct 15, 2024
1 parent cd14bdd commit fa4b2cf
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions source/php/Component/Image/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ public function init()

// Build img attributes
$this->data['imgAttributes'] = self::buildAttributes($this->data['imgAttributeList']);

// Add class if alt-text is missing
if (empty($this->data['alt'])) {
$this->data['attributeList']['data-a11y-error'] = "Alt text is missing";
}
}

private function addPlaceholderClass($src)
Expand Down

0 comments on commit fa4b2cf

Please sign in to comment.