Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
  • #1179198


    we need to remove the alt tag from the images in the “Blog Posts” component since the alt attribute is just a repeat of the text below the image – it leads to a duplication for screenreaders

    is there any kind of hook/filter we can use to replace it with alt="" ?



    Hey codemonkeynorth,

    No, there is no such filter. Please have a look at this file

    If you need further assistance please let us know.
    Best regards,


    it would appear to be part of config-templatebuilder\avia-shortcodes\postslider.php that the Blog Posts actually renders the item with, not blog.php.
    $output .= $thumbnail ? "<a href='{$link}' data-rel='slide-".avia_post_slider::$slide."' class='slide-image' title=''>{$thumbnail}</a>" : '';

    it’s the $thumbnail part we need to change in this instance to remove the alt

    the correct method seems to be passing false to the alt parameter in the third argument
    $thumbnail = get_the_post_thumbnail( $the_id, $image_size, array( 'alt' => false ));

    we don’t really want to edit core theme files and I imagine this solution would normally be preferable, using a regex

    add_filter( 'post_thumbnail_html', 'remove_thumbnail_alt', 10, 5 );
    function remove_thumbnail_alt( $html, $post_id, $post_thumbnail_id, $size, $attr ) {
        $html = preg_replace( '/(alt)=\"(.*?)\"\s/', "", $html );
        return $html;

    however I’m not sure we can run this function for only the blog posts entries

    if we need to add a conditional to the core postslider.php file output to remove the alt if a title is available in the pod text, we need to make it a conditional on these render types
    title, excerpt_read_more, title_read_more

    therefore for now I’ve added a patch to postslider.php

    // patch: remove alt on image if there is a title output on the pod
    // $thumbnail  = get_the_post_thumbnail( $the_id, $image_size );
    $hasTitle = in_array($contents, ['title', 'excerpt', 'excerpt_read_more', 'title_read_more']);
    $thumbnail  = get_the_post_thumbnail( $the_id, $image_size, ($hasTitle ? array('alt' => false) : null));

    again we’d rather not edit core theme files, but I see no other solution really using filters/hooks


    Hi codemonkeynorth,

    Well, you did not specify the element you were using so I suggested that file. Well, you can copy this file to the child theme and do your changes there.

    Best regards,



    It’s the “Blog Posts” component. This appears to use postslider.php, however when I copy it to my child theme with the same path it does not seem to pick up the new code

    please can you confirm that placing it at
    should allow me to change it there?

    I’m not sure why it didn’t work if that’s the case, unless it’s a caching issue




    Thank you for the update.

    You have to register a new path for the shortcodes in the child theme directory. Please check the documentation below.


    Create a folder in the child theme called shortcodes, then create a copy of the postslider templates inside it to override the original shortcode.

    Best regards,


    thanks that works for me!



    Did you need additional help or shall we close this topic?

    Best regards,
    Jordan Shannon


    Our workaround will do for now thanks so the topic can be closed, but please be aware of the accessibility issues with the theme .


    Hi codemonkeynorth,

    We’re glad to hear that :)
    Thanks for using Enfold and have a great day!

    Best regards,

Viewing 10 posts - 1 through 10 (of 10 total)
  • The topic ‘accessibility: blog posts component’ is closed to new replies.