$inner_block ) { if ( 'core/image' === $inner_block['blockName'] ) { if ( ! isset( $parsed_block['innerBlocks'][ $key ]['attrs']['data-id'] ) && isset( $inner_block['attrs']['id'] ) ) { $parsed_block['innerBlocks'][ $key ]['attrs']['data-id'] = esc_attr( $inner_block['attrs']['id'] ); } } } } return $parsed_block; } add_filter( 'render_block_data', 'block_core_gallery_data_id_backcompatibility' ); /** * Registers the `core/gallery` block on server. * This render callback needs to be here * so that the gallery styles are loaded in block-based themes. */ function register_block_core_gallery() { register_block_type_from_metadata( __DIR__ . '/gallery', array( 'render_callback' => function ( $attributes, $content ) { return $content; }, ) ); } add_action( 'init', 'register_block_core_gallery' );