Changeset 57254 for trunk/src/wp-includes/block-supports/background.php
- Timestamp:
- 01/09/2024 06:10:09 AM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/block-supports/background.php
r56731 r57254 41 41 * 42 42 * @since 6.4.0 43 * @since 6.5.0 Added support for `backgroundPosition` and `backgroundRepeat` output. 43 44 * @access private 44 45 * … … 65 66 ? $block_attributes['style']['background']['backgroundImage']['url'] 66 67 : null; 68 69 if ( ! $background_image_source && ! $background_image_url ) { 70 return $block_content; 71 } 72 67 73 $background_size = isset( $block_attributes['style']['background']['backgroundSize'] ) 68 74 ? $block_attributes['style']['background']['backgroundSize'] 69 75 : 'cover'; 76 $background_position = isset( $block_attributes['style']['background']['backgroundPosition'] ) 77 ? $block_attributes['style']['background']['backgroundPosition'] 78 : null; 79 $background_repeat = isset( $block_attributes['style']['background']['backgroundRepeat'] ) 80 ? $block_attributes['style']['background']['backgroundRepeat'] 81 : null; 70 82 71 83 $background_block_styles = array(); … … 77 89 // Set file based background URL. 78 90 $background_block_styles['backgroundImage']['url'] = $background_image_url; 79 // Only output the background size when an image url is set. 80 $background_block_styles['backgroundSize'] = $background_size; 91 // Only output the background size and repeat when an image url is set. 92 $background_block_styles['backgroundSize'] = $background_size; 93 $background_block_styles['backgroundRepeat'] = $background_repeat; 94 $background_block_styles['backgroundPosition'] = $background_position; 95 96 // If the background size is set to `contain` and no position is set, set the position to `center`. 97 if ( 'contain' === $background_size && ! isset( $background_position ) ) { 98 $background_block_styles['backgroundPosition'] = 'center'; 99 } 81 100 } 82 101 … … 100 119 $updated_style .= $styles['css']; 101 120 $tags->set_attribute( 'style', $updated_style ); 121 $tags->add_class( 'has-background' ); 102 122 } 103 123
Note: See TracChangeset
for help on using the changeset viewer.