tags that have none, keyed by file stem.
*
* @param string $html HTML to edit.
* @param array $alts Map of alexibility_fixes_wp_stem() => alt text ('' marks the image decorative).
* @param array $replace Stems whose empty alt="" is replaced too (an image that is a link's only content).
* @return array [ edited html, number of images changed ]
*/
function alexibility_fixes_add_img_alt( $html, $alts, $replace = array() ) {
if ( ! $alts || false === stripos( $html, '
next_tag( 'img' ) ) {
$src = $p->get_attribute( 'src' );
if ( ! is_string( $src ) ) {
continue;
}
$stem = alexibility_fixes_wp_stem( alexibility_fixes_file_name_of( $src ) );
if ( ! alexibility_fixes_alt_missing( $p->get_attribute( 'alt' ), in_array( $stem, $replace, true ) ) ) {
continue;
}
if ( array_key_exists( $stem, $alts ) ) {
$p->set_attribute( 'alt', $alts[ $stem ] );
++$count;
}
}
return array( $p->get_updated_html(), $count );
}
/** Whether an image's alt needs setting: none at all, or an empty one when the fix replaces empty alts. */
function alexibility_fixes_alt_missing( $alt, $replace_empty ) {
return null === $alt || ( $replace_empty && is_string( $alt ) && '' === trim( $alt ) );
}
/**
* Hides graphics that only repeat their control's name: aria-hidden="true" focusable="false" on