Make WordPress Core


Ignore:
Timestamp:
03/09/2025 09:14:28 AM (2 months ago)
Author:
audrasjb
Message:

Media: Improve HTML5 compliance of wp_video_shortcode() boolean attributes.

This changeset updates wp_video_shortcode() to improve boolean attributes handling in accordance with HTML5 standards. Technically, it replaces attr="1" with attr for the loop, autoplay and muted attributes. The preload attribute is also updated to accept only allowed values: none, metadata, and auto. If a value outside of this list is provided, it will be ignored, preventing invalid attribute outputs.

Props jongycastillo, sabernhardt, joedolson, audrasjb, shub07, debarghyabanerjee.
Fixes #60178.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/media.php

    r59473 r59954  
    10611061                'autoplay' => true,
    10621062                'muted'    => true,
    1063                 'preload'  => true,
     1063                'preload'  => 'metadata',
    10641064                'width'    => 123,
    10651065                'height'   => 456,
     
    10701070        $this->assertStringContainsString( 'src="https://example.com/foo.mp4', $actual );
    10711071        $this->assertStringContainsString( 'poster="https://example.com/foo.png', $actual );
    1072         $this->assertStringContainsString( 'loop="1"', $actual );
    1073         $this->assertStringContainsString( 'autoplay="1"', $actual );
     1072        $this->assertStringContainsString( 'loop', $actual );
     1073        $this->assertStringContainsString( 'autoplay', $actual );
    10741074        $this->assertStringContainsString( 'muted', $actual );
    1075         $this->assertStringContainsString( 'preload="1"', $actual );
     1075        $this->assertStringContainsString( 'preload="metadata"', $actual );
    10761076        $this->assertStringContainsString( 'width="123"', $actual );
    10771077        $this->assertStringContainsString( 'height="456"', $actual );
Note: See TracChangeset for help on using the changeset viewer.