[Support request] Dynamic Image: open link in new window

Home Forums Support [Support request] Dynamic Image: open link in new window

Home Forums Support Dynamic Image: open link in new window

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #1974813
    Stephane Bergeron

    Hi,

    I’m wondering if there’s a setting I’m overlooking but I’M trying to use a Dynamic Image block in a GPP content template and I’m using a Pods URL field for the Dynamic Image block but, since these URLs are to external sites, I’d want to open the link in a new tab using standard target=”_blank” but I see no setting to specify to open the dynamic link in a new window.

    If that is not possible, consider this a feature request ๐Ÿ˜‰ If it is possible, how?

    THanks!

    #1975136
    Ying
    Staff
    Customer Support

    Hi Stephane,

    Give this PHP snippet a try:

    add_filter( 'render_block', function( $block_content, $block ) {
        if ( 'generatepress/dynamic-image' === $block['blockName'] ) {
            $block_content = str_replace( '<a ', '<a target="_blank" ', $block_content );
        }
    
        return $block_content;
    }, 10, 2 );

    Adding PHP: https://docs.generatepress.com/article/adding-php/

    Let me know ๐Ÿ™‚

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