Make WordPress Core


Ignore:
Timestamp:
07/31/2024 02:39:46 AM (19 months ago)
Author:
ramonopoly
Message:

Background: add background attachment support to theme.json styles

Introduces the ability to specify a value for background.backgroundAttachment in theme.json styles.

The theme.json value determines the CSS value for the background-attachment property.

This feature was introduced into the Gutenberg plugin in version 18.9.

Props andrewserong, mukesh27, noisysocks, ramonopoly.

Fixes #61720

File:
1 edited

Legend:

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

    r58222 r58834  
    7070     * @ticket 60175
    7171     * @ticket 61123
     72     * @ticket 61720
    7273     *
    7374     * @covers ::wp_render_background_support
     
    140141                'wrapper'             => '<div>Content</div>',
    141142            ),
    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                     ),
    152                     'backgroundRepeat' => 'no-repeat',
    153                     'backgroundSize'   => 'contain',
    154                 ),
    155                 '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>',
     143            'background image style with contain, position, attachment, and repeat is applied' => array(
     144                'theme_name'          => 'block-theme-child-with-fluid-typography',
     145                'block_name'          => 'test/background-rules-are-output',
     146                'background_settings' => array(
     147                    'backgroundImage' => true,
     148                ),
     149                'background_style'    => array(
     150                    'backgroundImage'      => array(
     151                        'url' => 'https://example.com/image.jpg',
     152                    ),
     153                    'backgroundRepeat'     => 'no-repeat',
     154                    'backgroundSize'       => 'contain',
     155                    'backgroundAttachment' => 'fixed',
     156                ),
     157                '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;background-attachment:fixed;">Content</div>',
    156158                'wrapper'             => '<div>Content</div>',
    157159            ),
Note: See TracChangeset for help on using the changeset viewer.