-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
playsinline
attribute to cover block. (#22346)
This allows videos to generally autoplay on mobile devices. It registers a server callback for dealing with existing background videos and the lack of kses support for the attribute.
- Loading branch information
Showing
15 changed files
with
52 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
/** | ||
* Server-side rendering of the `core/cover` block. | ||
* | ||
* @package WordPress | ||
*/ | ||
|
||
/** | ||
* Supports `playsinline` attribute server side for `core/cover`. | ||
* | ||
* @param array $attributes The block attributes. | ||
* @param string $content HTML content of the block. | ||
* | ||
* @return string Rendered HTML of the referenced block. | ||
*/ | ||
function render_block_core_cover( $attributes, $content ) { | ||
if ( isset( $attributes['backgroundType'] ) && 'video' === $attributes['backgroundType'] ) { | ||
return str_replace( 'autoplay muted', 'autoplay muted playsinline', $content ); | ||
} | ||
|
||
return $content; | ||
} | ||
|
||
/** | ||
* Registers the `core/cover` block. | ||
*/ | ||
function register_block_core_cover() { | ||
register_block_type_from_metadata( | ||
__DIR__ . '/cover', | ||
array( | ||
'render_callback' => 'render_block_core_cover', | ||
) | ||
); | ||
} | ||
add_action( 'init', 'register_block_core_cover' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/e2e-tests/fixtures/blocks/core__cover__gradient-video.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.