How to render core/image block only if inside a core/gallery block ?
-
Hi,
I have this hook in my functions.phpfunction 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
- The topic ‘How to render core/image block only if inside a core/gallery block ?’ is closed to new replies.