WP_Widget_Media_Video::inject_video_max_width_style() WordPress Method
The WP_Widget_Media_Video::inject_video_max_width_style() method is used to inject the max-width style for the video player. This is used to ensure that the video player does not exceed the width of the container.
WP_Widget_Media_Video::inject_video_max_width_style( string $html ) #
Inject max-width and remove height for videos too constrained to fit inside sidebars on frontend.
Parameters
- $html
(string)(Required)Video shortcode HTML output.
Return
(string) HTML Output.
Source
File: wp-includes/widgets/class-wp-widget-media-video.php
public function inject_video_max_width_style( $html ) { $html = preg_replace( '/\sheight="\d+"/', '', $html ); $html = preg_replace( '/\swidth="\d+"/', '', $html ); $html = preg_replace( '/(?<=width:)\s*\d+px(?=;?)/', '100%', $html ); return $html; }
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
Version | Description |
---|---|
4.8.0 | Introduced. |