diff --git a/lib/block-supports/background.php b/lib/block-supports/background.php
index 70957897229595..acecf5dcbcea80 100644
--- a/lib/block-supports/background.php
+++ b/lib/block-supports/background.php
@@ -67,7 +67,7 @@ function gutenberg_render_background_support( $block_content, $block ) {
}
$styles = gutenberg_style_engine_get_styles( array( 'background' => $background_styles ) );
-
+var_dump( $block_attributes['style']['background'] );
if ( ! empty( $styles['css'] ) ) {
// Inject background styles to the first element, presuming it's the wrapper, if it exists.
$tags = new WP_HTML_Tag_Processor( $block_content );
diff --git a/lib/class-wp-theme-json-gutenberg.php b/lib/class-wp-theme-json-gutenberg.php
index 77004253bea868..21d2fc59037bff 100644
--- a/lib/class-wp-theme-json-gutenberg.php
+++ b/lib/class-wp-theme-json-gutenberg.php
@@ -223,6 +223,7 @@ class WP_Theme_JSON_Gutenberg {
'background-position' => array( 'background', 'backgroundPosition' ),
'background-repeat' => array( 'background', 'backgroundRepeat' ),
'background-size' => array( 'background', 'backgroundSize' ),
+ 'background-attachment' => array( 'background', 'backgroundAttachment' ),
'border-radius' => array( 'border', 'radius' ),
'border-top-left-radius' => array( 'border', 'radius', 'topLeft' ),
'border-top-right-radius' => array( 'border', 'radius', 'topRight' ),
@@ -488,10 +489,11 @@ class WP_Theme_JSON_Gutenberg {
*/
const VALID_STYLES = array(
'background' => array(
- 'backgroundImage' => 'top',
- 'backgroundPosition' => 'top',
- 'backgroundRepeat' => 'top',
- 'backgroundSize' => 'top',
+ 'backgroundImage' => 'top',
+ 'backgroundAttachment' => 'top',
+ 'backgroundPosition' => 'top',
+ 'backgroundRepeat' => 'top',
+ 'backgroundSize' => 'top',
),
'border' => array(
'color' => null,
diff --git a/packages/block-editor/src/components/global-styles/background-panel.js b/packages/block-editor/src/components/global-styles/background-panel.js
index f45c787e45589b..38b63c8a98e11b 100644
--- a/packages/block-editor/src/components/global-styles/background-panel.js
+++ b/packages/block-editor/src/components/global-styles/background-panel.js
@@ -191,6 +191,7 @@ function BackgroundImageToolsPanelItem( {
onChange,
style,
inheritedValue,
+ settings,
} ) {
const mediaUpload = useSelect(
( select ) => select( blockEditorStore ).getSettings().mediaUpload,
@@ -201,6 +202,13 @@ function BackgroundImageToolsPanelItem( {
...inheritedValue?.background?.backgroundImage,
};
+ const shouldShowBackgroundAttachmentControls =
+ settings?.background?.backgroundAttachment;
+
+ const attachmentValue = style?.background?.backgroundAttachment || {
+ ...inheritedValue?.background?.backgroundAttachment,
+ };
+
const replaceContainerRef = useRef();
const { createErrorNotice } = useDispatch( noticesStore );
@@ -275,10 +283,21 @@ function BackgroundImageToolsPanelItem( {
};
}, [] );
+ const toggleScrollWithPage = () =>
+ onChange(
+ setImmutably(
+ style,
+ [ 'background', 'backgroundAttachment' ],
+ attachmentValue === 'fixed' ? 'scroll' : 'fixed'
+ )
+ );
+
const hasValue = hasBackgroundImageValue( style );
return (
-