--- a/wp/wp-includes/block-supports/background.php Fri Sep 05 18:40:08 2025 +0200
+++ b/wp/wp-includes/block-supports/background.php Fri Sep 05 18:52:52 2025 +0200
@@ -42,6 +42,7 @@
* @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,17 +63,19 @@
return $block_content;
}
- $background_styles = array();
- $background_styles['backgroundImage'] = isset( $block_attributes['style']['background']['backgroundImage'] ) ? $block_attributes['style']['background']['backgroundImage'] : array();
+ $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'] = isset( $block_attributes['style']['background']['backgroundSize'] ) ? $block_attributes['style']['background']['backgroundSize'] : 'cover';
- $background_styles['backgroundPosition'] = isset( $block_attributes['style']['background']['backgroundPosition'] ) ? $block_attributes['style']['background']['backgroundPosition'] : null;
- $background_styles['backgroundRepeat'] = isset( $block_attributes['style']['background']['backgroundRepeat'] ) ? $block_attributes['style']['background']['backgroundRepeat'] : null;
+ $background_styles['backgroundSize'] = $background_styles['backgroundSize'] ?? 'cover';
// If the background size is set to `contain` and no position is set, set the position to `center`.
if ( 'contain' === $background_styles['backgroundSize'] && ! $background_styles['backgroundPosition'] ) {
- $background_styles['backgroundPosition'] = 'center';
+ $background_styles['backgroundPosition'] = '50% 50%';
}
}