• Hi,

    I have this hook in my functions.php

    function change_block_image( $block_content, $block ){
    $block_content = '';
    foreach( (array) $block['attrs']['id'] as $id ) {
    $image_medium_attributes_array = wp_get_attachment_image_src( $id, 'medium' );
    $image_originale_attributes_array = wp_get_attachment_image_src( $id, 'full' );
    $block_content .= '<a href="'. $image_originale_attributes_array[0] .'"><img class="img-thumbnail" src="'. $image_medium_attributes_array[0] .'"></a>';
    }
    return $block_content;
    }
    add_filter( 'render_block_core/image', 'change_block_image', 10, 2 );


    It works well, but now I want to apply this filter only if the image is inside a gallery.

    Do you know to achieve this ?

    Thanks

    • This topic was modified 1 year, 11 months ago by charlie67p.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to render core/image block only if inside a core/gallery block ?’ is closed to new replies.