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

    Hi,

    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="" ?

    thanks

    #1179551

    Hey codemonkeynorth,

    No, there is no such filter. Please have a look at this file
    /enfold/config-templatebuilder/avia-shortcodes/blog/blog.php

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

    #1179609

    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

    #1179964

    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,
    Victoria

    #1180085

    Hi.

    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
    my-child-theme\config-templatebuilder\avia-shortcodes\postslider.php
    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

    Thanks
    Joe

    #1181135

    Hi,

    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.

    // https://kriesi.at/documentation/enfold/intro-to-layout-builder/#add-elements-to-alb

    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,
    Ismael

    #1181305

    thanks that works for me!

    #1181500

    Hi,

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

    Best regards,
    Jordan Shannon

    #1181576

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

    #1181691

    Hi codemonkeynorth,

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

    Best regards,
    Nikko

Viewing 10 posts - 1 through 10 (of 10 total)

The topic ‘accessibility: blog posts component’ is closed to new replies.