Background: add background attachment support to theme.json styles
Introduces the ability to specify a value for `background.backgroundAttachment` in theme.json styles. The theme.json value determines the CSS value for the `background-attachment` property. This feature was introduced into the Gutenberg plugin in version 18.9. Props andrewserong, mukesh27, noisysocks, ramonopoly. Fixes #61720 Built from https://develop.svn.wordpress.org/trunk@58834 git-svn-id: http://core.svn.wordpress.org/trunk@58230 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
@@ -42,6 +42,7 @@ function wp_register_background_support( $block_type ) {
|
||||
* @since 6.4.0
|
||||
* @since 6.5.0 Added support for `backgroundPosition` and `backgroundRepeat` output.
|
||||
* @since 6.6.0 Removed requirement for `backgroundImage.source`. A file/url is the default.
|
||||
* @since 6.7.0 Added support for `backgroundAttachment` output.
|
||||
*
|
||||
* @access private
|
||||
*
|
||||
@@ -62,11 +63,12 @@ function wp_render_background_support( $block_content, $block ) {
|
||||
return $block_content;
|
||||
}
|
||||
|
||||
$background_styles = array();
|
||||
$background_styles['backgroundImage'] = $block_attributes['style']['background']['backgroundImage'] ?? null;
|
||||
$background_styles['backgroundSize'] = $block_attributes['style']['background']['backgroundSize'] ?? null;
|
||||
$background_styles['backgroundPosition'] = $block_attributes['style']['background']['backgroundPosition'] ?? null;
|
||||
$background_styles['backgroundRepeat'] = $block_attributes['style']['background']['backgroundRepeat'] ?? null;
|
||||
$background_styles = array();
|
||||
$background_styles['backgroundImage'] = $block_attributes['style']['background']['backgroundImage'] ?? null;
|
||||
$background_styles['backgroundSize'] = $block_attributes['style']['background']['backgroundSize'] ?? null;
|
||||
$background_styles['backgroundPosition'] = $block_attributes['style']['background']['backgroundPosition'] ?? null;
|
||||
$background_styles['backgroundRepeat'] = $block_attributes['style']['background']['backgroundRepeat'] ?? null;
|
||||
$background_styles['backgroundAttachment'] = $block_attributes['style']['background']['backgroundAttachment'] ?? null;
|
||||
|
||||
if ( ! empty( $background_styles['backgroundImage'] ) ) {
|
||||
$background_styles['backgroundSize'] = $background_styles['backgroundSize'] ?? 'cover';
|
||||
|
||||
Reference in New Issue
Block a user