Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update tests and perform check for background size before use.
  • Loading branch information
ramonjd committed Aug 15, 2024
commit bc8dcc3cdc982e2805a515bd2a0cfecc233dad4c
5 changes: 3 additions & 2 deletions lib/class-wp-theme-json-gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -2400,8 +2400,9 @@ protected static function compute_style_properties( $styles, $settings = array()
$value = 'cover';
}
// If the background size is set to `contain` and no position is set, set the position to `center`.
if ( 'background-position' === $css_property && 'contain' === $styles['background']['backgroundSize'] ) {
$value = '50% 50%';
if ( 'background-position' === $css_property ) {
$background_size = $styles['background']['backgroundSize'] ?? null;
$value = 'contain' === $background_size ? '50% 50%' : null;
}
}

Expand Down
2 changes: 2 additions & 0 deletions phpunit/class-wp-theme-json-test.php
Original file line number Diff line number Diff line change
Expand Up @@ -4898,6 +4898,8 @@ public function test_get_block_background_image_styles() {
'backgroundImage' => array(
'url' => 'http://example.org/verse.png',
'id' => 123,
// Merged theme.json and global styles will retain the "ref" value.
'ref' => 'styles.background.backgroundImage',
),
),
),
Expand Down