s3rgiosan / wp-media-chrome
Package info
github.com/s3rgiosan/wp-media-chrome
Type:wordpress-plugin
pkg:composer/s3rgiosan/wp-media-chrome
Requires
- php: ^7.4|^8.0
- composer-plugin-api: ^2.3
- yahnis-elsts/plugin-update-checker: ^5.5
Requires (Dev)
- pixelalbatross/coding-standards: dev-main
README
Enhance your video and audio blocks with custom web components from Media Chrome.
Description
Media Chrome for Embed Blocks brings the power of Media Chrome to WordPress embed blocks. It enhances built-in video and audio embed blocks with custom web components, improving player controls, accessibility, and user experience. No setup required — just activate the plugin to enhance media blocks with better controls, improved accessibility, and a modernized playback experience.
Supported Media Blocks
(*) Spotify support is disabled by default due to its limited customization options and UI. To enable it, see the Spotify section below.
Requirements
- WordPress 6.7 or later
- PHP 7.4 or later
Installation
Manual Installation
- Download the plugin ZIP file from the GitHub repository.
- Go to Plugins > Add New > Upload Plugin in your WordPress admin area.
- Upload the ZIP file and click Install Now.
- Activate the plugin.
Install with Composer
To include this plugin as a dependency in your Composer-managed WordPress project:
- Add the plugin to your project using the following command:
composer require s3rgiosan/wp-media-chrome
- Run
composer installto install the plugin. - Activate the plugin from your WordPress admin area or using WP-CLI.
Quick Start
Once activated, the plugin automatically enhances supported media blocks. Customization is optional but available via the block editor settings or theme.json.
To customize a media player:
- Insert a supported media block
- Select the block to reveal its settings in the block editor sidebar
- Open the Media Chrome settings panel in the sidebar to enable or disable autoplay, playback speed adjustments, or fullscreen mode.
Block Editor
UI Settings
What options users see in the editor.
UI settings control which customization options appear in the block editor. They do not affect the media player's behavior on the frontend — only what users can modify.
By default, all customization options are enabled.
To limit available options, add the following to your theme.json (example shows all options enabled for the video embed block):
{
"$schema": "https://schemas.wp.org/wp/6.7/theme.json",
"version": 2,
"settings": {
"custom": {
"mediaChrome": {
"ui": {
"embed": {
"video": {
"muted": true,
"controls": true,
"playsInline": true,
"preload": true,
"poster": true,
"autohide": true,
"playButton": true,
"seekBackwardButton": true,
"seekForwardButton": true,
"muteButton": true,
"volumeRange": true,
"timeDisplay": true,
"timeRange": true,
"playbackRateButton": true,
"fullscreenButton": true,
"airplayButton": true
}
}
}
}
}
}
}
Preset Settings
What default values are used when no user preference is set.
Preset settings define default values for media player options when no user preference is set. If a user customizes a setting in the block editor, that value takes precedence. If no preset is set in theme.json, the plugin uses built-in defaults (listed in Options).
Example video embed preset configuration for your theme.json:
{
"$schema": "https://schemas.wp.org/wp/6.7/theme.json",
"version": 2,
"settings": {
"custom": {
"mediaChrome": {
"presets": {
"embed": {
"video": {
"autohide": 2,
"muted": false,
"controls": true,
"playsInline": false,
"preload": "metadata",
"poster": "",
"playButton": true,
"seekBackwardButton": true,
"seekForwardButton": true,
"muteButton": true,
"volumeRange": true,
"timeDisplay": true,
"timeRange": true,
"playbackRateButton": true,
"fullscreenButton": true,
"airplayButton": false
}
}
}
}
}
}
}
Options
Embed
autohide
Number of seconds after which controls auto-hide when inactive. Set to -1 to disable auto-hide.
Default: 2
muted
Determines if media starts muted.
Default: false
controls
Toggles the display of media controls.
Default: true
playsInline
When enabled, videos play inline on mobile devices rather than opening in fullscreen. Only available for embed video blocks.
Default: false
preload
Defines the content that is preloaded. Options include 'auto', 'metadata', and 'none'.
Default: 'metadata'
poster
URL for the poster image displayed before playback starts. Only available for embed video blocks.
Default: ''
playButton
Whether to display the play/pause button in the control bar.
Default: true
seekBackwardButton
Whether to display the button for seeking backward.
Default: true
seekForwardButton
Whether to display the button for seeking forward.
Default: true
muteButton
Whether to display the mute/unmute button. Only available for video blocks.
Default: true
volumeRange
Whether to show the volume slider. Only available for video blocks.
Default: true
timeDisplay
Whether to show the current time and duration of the media.
Default: true
timeRange
Whether to display the timeline or progress bar.
Default: true
playbackRateButton
Whether to include a control for adjusting playback speed. Only available for video blocks.
Default: true
fullscreenButton
Whether to display the fullscreen toggle button. Only available for video blocks.
Default: true
airplayButton
Whether to display the AirPlay button (only supported in Safari). Only available for video blocks.
Default: false
Spotify
Spotify support is disabled by default. To enable it, add the following:
PHP (functions.php or a custom plugin)
add_filter( 'media_chrome_providers_audio', function ( $providers ) { $providers[] = S3S\WP\MediaChrome\Provider\Spotify::class; return $providers; });
JavaScript (theme JavaScript file or a custom plugin)
addFilter('mediaChrome.providers.audio', 'my-plugin/enable-spotify', (providers) => { return [...providers, 'spotify']; });
Styling
Media Chrome components can be fully styled with CSS to match your site's design. For complete styling documentation, see the Media Chrome styling documentation.
Example of basic styling customization:
/* Change the color of the media controls */ media-control-bar { --media-control-background: rgba(0, 0, 0, 0.7); --media-control-hover-background: rgba(0, 0, 0, 0.9); } /* Style the play button */ media-play-button { --media-button-icon-width: 24px; --media-button-icon-height: 24px; --media-button-icon-transform: scale(1.2); }
Hooks
PHP Filters
media_chrome_providers_video
Filters the list of enabled video providers. Receives an array of provider class names.
Default providers: Vimeo, Wistia, YouTube.
add_filter( 'media_chrome_providers_video', function ( $providers ) { return array_filter( $providers, fn( $p ) => $p !== \S3S\WP\MediaChrome\Provider\Wistia::class ); });
media_chrome_providers_audio
Filters the list of enabled audio providers. Empty by default.
add_filter( 'media_chrome_providers_audio', function ( $providers ) { $providers[] = \S3S\WP\MediaChrome\Provider\Spotify::class; return $providers; });
media_chrome_controller_attributes
Filters the <media-controller> element HTML attributes.
Parameters:
$attributes(array) — HTML attributes.$block_attrs(array) — Block attributes.$custom_settings(array) — Merged custom settings.
media_chrome_poster_image_attributes
Filters the <media-poster-image> element HTML attributes.
Parameters:
$attributes(array) — HTML attributes.$block_attrs(array) — Block attributes.$custom_settings(array) — Merged custom settings.
media_chrome_control_bar_components
Filters the components displayed in the media control bar.
Parameters:
$components(array) — Array of component configurations keyed by tag name.
media_chrome_control_bar_{$component}_slots
Filters the slots for a specific control bar component. The {$component} placeholder uses underscores instead of hyphens (e.g., media_chrome_control_bar_media_play_button_slots).
Parameters:
$slots(array) — Array of slot content keyed by slot name.$block_attrs(array) — Block attributes.
add_filter( 'media_chrome_control_bar_media_play_button_slots', function ( $slots, $block_attrs ) { $slots['icon'] = '<svg>...</svg>'; return $slots; }, 10, 2 );
media_chrome_allowed_tags
Filters the allowed HTML tags and attributes for control bar slot content (passed to wp_kses).
Parameters:
$allowed_tags(array) — Array of allowed tags and their attributes.
media_chrome_{$slug}_provider_attributes
Filters the HTML attributes for a specific provider element. Replace {$slug} with the provider slug (e.g., youtube, vimeo, wistia, spotify).
Parameters:
$attributes(array) — HTML attributes.$slug(string) — Provider slug.
add_filter( 'media_chrome_youtube_provider_attributes', function ( $attributes, $slug ) { $attributes['crossorigin'] = 'anonymous'; return $attributes; }, 10, 2 );
JavaScript Filters
mediaChrome.providers.video
Filters the list of supported video provider slugs in the block editor.
Default: ['youtube', 'vimeo', 'wistia']
mediaChrome.providers.audio
Filters the list of supported audio provider slugs in the block editor.
Default: []
Changelog
A complete listing of all notable changes to this project are documented in CHANGELOG.md.
License and Attribution
This plugin is licensed under MIT.
This project incorporates Media Chrome, which is licensed under the MIT License.