Are you a GenerateCustomer?

Do you have an active GP Premium or GenerateBlocks Pro license key?

Create a GenerateSupport account for GeneratePress and GenerateBlocks support in one dedicated place.

Create an account
Already have a GenerateSupport account? Login

Just browsing?

Feel free to browse the forums. Support for our free versions is provided on (GeneratePress, GenerateBlocks).

Want to become a premium user? Learn more below.

Alt tag on GB Image with Dynamic Data

  • 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:

    block structure

    Dynamic Data seems to ignore the Alt:

    No Alt in code

    Normally there is an alt on my image:

    alt on the file

    Is this a bug?
    Is there a way for Dynamic Data to retrieve the alt tag as well?


  • 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!

  • 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 🙂

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.