-
Chaplin89
Hello,
I’m working on improving the accessibility of my site. In particular, the addition of “alt” tags on each image.
At the end of each post, I have this structure:
Dynamic Data seems to ignore the Alt:
Normally there is an alt on my image:
Is this a bug?
Is there a way for Dynamic Data to retrieve the alt tag as well?Thanks
-
Hi there,
I just tested on my site, and the alt text is showing correctly.
Can you try disabling all other plugins to eliminate plugin conflicts?
If it’s still the case, try disabling all your custom functions as well.
Let me know how it goes!
-
Chaplin89
Hello Ying,
Indeed it was a mistake on my part. I use a special custom system, which retrieves the url of the image to display via a meta of the post configured with ACF 🙂
The only solution for me, which works, is to use this filter, activated according to a CSS class:
add_filter( 'render_block', 'pbx_add_alt_tag_on_dynamic_image', 10, 2 ); function pbx_add_alt_tag_on_dynamic_image( string $block_content, array $block ) { if( 'generateblocks/image' === $block['blockName'] ) { if( false !== strpos( $block['attrs']['className'], 'pbx-alt-nsp' ) ) { return str_replace( '<img ', '<img alt="' . esc_attr__( 'My alt text', 'pbx' ) . '" ', $block_content ); } } return $block_content; }
Have a nice day
-
Good job on that 🙂
- You must be logged in to reply to this topic.