diff --git a/packages/block-library/src/gallery/index.php b/packages/block-library/src/gallery/index.php index 09875db4279286..e73a092e88067e 100644 --- a/packages/block-library/src/gallery/index.php +++ b/packages/block-library/src/gallery/index.php @@ -32,6 +32,17 @@ function block_core_gallery_data_id_backcompatibility( $parsed_block ) { add_filter( 'render_block_data', 'block_core_gallery_data_id_backcompatibility' ); +/** + * Adds a style tag for the --wp--style--unstable-gallery-gap var. + * + * The Gallery block needs to recalculate Image block width based on + * the current gap setting in order to maintain the number of flex columns + * so a css var is added to allow this. + * + * @param array $attributes Attributes of the block being rendered. + * @param string $content Content of the block being rendered. + * @return string The content of the block being rendered. + */ function block_core_gallery_render( $attributes, $content ) { $gap_value = _wp_array_get( $attributes, array( 'style', 'spacing', 'blockGap' ) ); // Skip if gap value contains unsupported characters.