On this page
WP_Widget_Media_Video::inject_video_max_width_style( string $html ): string
Inject max-width and remove height for videos too constrained to fit inside sidebars on frontend.
Parameters
$htmlstring Required-
Video shortcode HTML output.
Return
string HTML Output.
Source
File: wp-includes/widgets/class-wp-widget-media-video.php. View all references
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;
}
Related
Used By
| Used By | Description |
|---|---|
| WP_Widget_Media_Video::render_media() wp-includes/widgets/class-wp-widget-media-video.php | Render the media on the frontend. |
Changelog
| Version | Description |
|---|---|
| 4.8.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_widget_media_video/inject_video_max_width_style