Make WordPress Core


Ignore:
Timestamp:
01/09/2024 06:10:09 AM (3 years ago)
Author:
isabel_brison
Message:

Editor: add size and repeat to background image support.

Adds background size and background repeat style processing to the background image block support and WP_Style_Engine definitions.

Props andrewserong, mukesh27.
Fixes #60175.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/block-supports/wpRenderBackgroundSupport.php

    r56614 r57254  
    6868         *
    6969         * @ticket 59357
     70         * @ticket 60175
    7071         *
    7172         * @covers ::wp_render_background_support
     
    136137                                        ),
    137138                                ),
    138                                 'expected_wrapper'    => '<div style="background-image:url(&#039;https://example.com/image.jpg&#039;);background-size:cover;">Content</div>',
     139                                'expected_wrapper'    => '<div class="has-background" style="background-image:url(&#039;https://example.com/image.jpg&#039;);background-size:cover;">Content</div>',
    139140                                'wrapper'             => '<div>Content</div>',
    140141                        ),
     142                        'background image style with contain, position, and repeat is applied' => array(
     143                                'theme_name'          => 'block-theme-child-with-fluid-typography',
     144                                'block_name'          => 'test/background-rules-are-output',
     145                                'background_settings' => array(
     146                                        'backgroundImage' => true,
     147                                ),
     148                                'background_style'    => array(
     149                                        'backgroundImage'  => array(
     150                                                'url'    => 'https://example.com/image.jpg',
     151                                                'source' => 'file',
     152                                        ),
     153                                        'backgroundRepeat' => 'no-repeat',
     154                                        'backgroundSize'   => 'contain',
     155                                ),
     156                                'expected_wrapper'    => '<div class="has-background" style="background-image:url(&#039;https://example.com/image.jpg&#039;);background-position:center;background-repeat:no-repeat;background-size:contain;">Content</div>',
     157                                'wrapper'             => '<div>Content</div>',
     158                        ),
    141159                        'background image style is appended if a style attribute already exists' => array(
    142160                                'theme_name'          => 'block-theme-child-with-fluid-typography',
     
    151169                                        ),
    152170                                ),
    153                                 'expected_wrapper'    => '<div classname="wp-block-test" style="color: red;background-image:url(&#039;https://example.com/image.jpg&#039;);background-size:cover;">Content</div>',
    154                                 'wrapper'             => '<div classname="wp-block-test" style="color: red">Content</div>',
     171                                'expected_wrapper'    => '<div class="wp-block-test has-background" style="color: red;background-image:url(&#039;https://example.com/image.jpg&#039;);background-size:cover;">Content</div>',
     172                                'wrapper'             => '<div class="wp-block-test" style="color: red">Content</div>',
    155173                        ),
    156174                        'background image style is appended if a style attribute containing multiple styles already exists' => array(
     
    166184                                        ),
    167185                                ),
    168                                 'expected_wrapper'    => '<div classname="wp-block-test" style="color: red;font-size: 15px;background-image:url(&#039;https://example.com/image.jpg&#039;);background-size:cover;">Content</div>',
    169                                 'wrapper'             => '<div classname="wp-block-test" style="color: red;font-size: 15px;">Content</div>',
     186                                'expected_wrapper'    => '<div class="wp-block-test has-background" style="color: red;font-size: 15px;background-image:url(&#039;https://example.com/image.jpg&#039;);background-size:cover;">Content</div>',
     187                                'wrapper'             => '<div class="wp-block-test" style="color: red;font-size: 15px;">Content</div>',
    170188                        ),
    171189                        'background image style is not applied if the block does not support background image' => array(
Note: See TracChangeset for help on using the changeset viewer.