Pokud řešíte přístupnost webu, děláte web v Bricks a máte jeh Bricks galerie, pak jste možná zjistitli, že nejsou kompletně připravené pro přístupnost webu (jsou to vlastně odkazy, ale nemají aria-label atributy). Následující kód nastaví udělá právě to, že vezme label z obrázku a nastaví ho odkazu.
/**
* Update bricks gallery to add aria-label to links
*/
function add_aria_label_to_gallery_link() {
echo '<script type="text/javascript">
document.addEventListener("DOMContentLoaded", function() {
var links = document.querySelectorAll(".brxe-image-gallery a");
links.forEach(function(link) {
var image = link.querySelector(".image");
var ariaLabel = image.getAttribute("aria-label");
if (ariaLabel) {
link.setAttribute("aria-label", ariaLabel);
}
});
});
</script>
';
}
add_action('wp_head', 'add_aria_label_to_gallery_link');
Stačí ho dát do child theme (nebo snippetu).

