From 47efd33167d97881d79d6a01a18d0198650de153 Mon Sep 17 00:00:00 2001 From: Steve Jones Date: Wed, 27 Mar 2024 10:17:07 -0400 Subject: [PATCH] Update includes/rules/img_alt_long.php Co-authored-by: William Patton --- includes/rules/img_alt_long.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/includes/rules/img_alt_long.php b/includes/rules/img_alt_long.php index d539431e..58c782e5 100644 --- a/includes/rules/img_alt_long.php +++ b/includes/rules/img_alt_long.php @@ -14,11 +14,18 @@ */ function edac_rule_img_alt_long( $content, $post ) { // phpcs:ignore -- $post is reserved for future use or for compliance with a specific interface. - $dom = $content['html']; - $errors = array(); - $images = $dom->find( 'img' ); - $max_alt_length = absint( apply_filters( 'edac_max_alt_length', 300 ) ); - $max_alt_length = max( 1, $max_alt_length ); + $dom = $content['html']; + $errors = array(); + $images = $dom->find( 'img' ); + + /** + * Filter the max alt text length checked by the img_alt_long rule before it is considered an issue. + * + * @since 1.11.0 + * + * @param int $length The length used in the rule to determine the max length before flagging as an issue. + */ + $max_alt_length = max( 1, absint( apply_filters( 'edac_max_alt_length', 300 ) ) ); foreach ( $images as $image ) { if ( isset( $image ) && $image->hasAttribute( 'alt' ) && $image->getAttribute( 'alt' ) !== '' ) {