Skip to content

Instantly share code, notes, and snippets.

@bdeleasa
Created June 5, 2023 17:31
Show Gist options
  • Save bdeleasa/6df493b17adf87850b18787bfefde0f3 to your computer and use it in GitHub Desktop.
Save bdeleasa/6df493b17adf87850b18787bfefde0f3 to your computer and use it in GitHub Desktop.
Adjust the .elementor-background-overlay element with a PHP filter to add the role="img" attribute for accessibility purposes.
<?php
add_filter( 'elementor/frontend/the_content', 'MYPREFIX_add_role_to_elementor_overlay' );
/**
* Find the <div class="elementor-background-overlay"></div> element and add the role="img" attribute
* to meet accessibility guidelines.
*
* @since 1.0.0
*
* @param $content
* @return string
*/
function MYPREFIX_add_role_to_elementor_overlay($content) {
$content = str_replace('<div class="elementor-background-overlay">', '<div class="elementor-background-overlay" role="img">', $content);
return $content;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment