Make WordPress Core

Changeset 54128


Ignore:
Timestamp:
09/11/2022 10:17:04 PM (18 months ago)
Author:
antpb
Message:

Media: Add muted property for video elements.

This change allows for the muted property to be used in video elements which solves for content that wishes to autoPlay when a page is viewed. Adding muted to video elements adhears to the requirements browsers have to honor autoPlay functionality.

Props prokium, peterwilsoncc, costdev, johnbillion, Benouare.
Fixes #54788.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/media.php

    r54097 r54128  
    32203220 *     @type string $loop     The 'loop' attribute for the `<video>` element. Default empty.
    32213221 *     @type string $autoplay The 'autoplay' attribute for the `<video>` element. Default empty.
     3222 *     @type string $muted    The 'muted' attribute for the `<video>` element. Default false.
    32223223 *     @type string $preload  The 'preload' attribute for the `<video>` element.
    32233224 *                            Default 'metadata'.
     
    32643265        'loop'     => '',
    32653266        'autoplay' => '',
     3267        'muted'    => 'false',
    32663268        'preload'  => 'metadata',
    32673269        'width'    => 640,
     
    33913393        'loop'     => wp_validate_boolean( $atts['loop'] ),
    33923394        'autoplay' => wp_validate_boolean( $atts['autoplay'] ),
     3395        'muted'    => wp_validate_boolean( $atts['muted'] ),
    33933396        'preload'  => $atts['preload'],
    33943397    );
    33953398
    33963399    // These ones should just be omitted altogether if they are blank.
    3397     foreach ( array( 'poster', 'loop', 'autoplay', 'preload' ) as $a ) {
     3400    foreach ( array( 'poster', 'loop', 'autoplay', 'preload', 'muted' ) as $a ) {
    33983401        if ( empty( $html_atts[ $a ] ) ) {
    33993402            unset( $html_atts[ $a ] );
  • trunk/tests/phpunit/tests/media.php

    r54097 r54128  
    10241024    /**
    10251025     * @ticket 35367
     1026     * @ticket 54788
    10261027     * @depends test_video_shortcode_body
    10271028     */
     
    10361037        $this->assertStringNotContainsString( 'loop', $actual );
    10371038        $this->assertStringNotContainsString( 'autoplay', $actual );
     1039        $this->assertStringNotContainsString( 'muted', $actual );
    10381040        $this->assertStringContainsString( 'preload="metadata"', $actual );
    10391041        $this->assertStringContainsString( 'width="640"', $actual );
     
    10471049                'loop'     => true,
    10481050                'autoplay' => true,
     1051                'muted'    => true,
    10491052                'preload'  => true,
    10501053                'width'    => 123,
     
    10581061        $this->assertStringContainsString( 'loop="1"', $actual );
    10591062        $this->assertStringContainsString( 'autoplay="1"', $actual );
     1063        $this->assertStringContainsString( 'muted', $actual );
    10601064        $this->assertStringContainsString( 'preload="1"', $actual );
    10611065        $this->assertStringContainsString( 'width="123"', $actual );
Note: See TracChangeset for help on using the changeset viewer.