WP_Widget_Media_Video::inject_video_max_width_style()
Inject max-width and remove height for videos too constrained to fit inside sidebars on frontend.
Method of the class: WP_Widget_Media_Video{}
No Hooks.
Return
String
. HTML Output.
Usage
$WP_Widget_Media_Video = new WP_Widget_Media_Video(); $WP_Widget_Media_Video->inject_video_max_width_style( $html );
- $html(string) (required)
- Video shortcode HTML output.
Changelog
Since 4.8.0 | Introduced. |
WP_Widget_Media_Video::inject_video_max_width_style() WP Widget Media Video::inject video max width style code WP 6.5.2
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; }