Skip to content
Prev Previous commit
Next Next commit
Adding a render function so that block based themes render the galler…
…y correctly. Without this dummy render function, the gallery styles do not load with the block-library build.
  • Loading branch information
ramonjd committed Nov 5, 2021
commit a958531b40bc7f78d4ac439a5a61ef5ca4360105
18 changes: 18 additions & 0 deletions packages/block-library/src/gallery/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,21 @@ function render_block_core_gallery_data( $parsed_block ) {
}

add_filter( 'render_block_data', 'render_block_core_gallery_data' );

/**
* 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 gutenberg_register_block_core_gallery() {
register_block_type_from_metadata(
__DIR__ . '/gallery',
array(
'render_callback' => function ( $attributes, $content ) {
return $content;
},
)
);
}

add_action( 'init', 'gutenberg_register_block_core_gallery', 20 );
2 changes: 1 addition & 1 deletion packages/block-library/src/image/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function render_block_core_image( $attributes, $content ) {


/**
* Register image block.
* Registers the `core/image` block on server.
*/
function register_block_core_image() {
register_block_type_from_metadata(
Expand Down