Skip to content

Commit

Permalink
Adding a render function so that block based themes render the galler…
Browse files Browse the repository at this point in the history
…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
1 parent fcd872f commit a958531
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
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

0 comments on commit a958531

Please sign in to comment.