WP_Widget_Media_Video::inject_video_max_width_style( string $html ): string

In this article

Inject max-width and remove height for videos too constrained to fit inside sidebars on frontend.

Parameters

$htmlstringrequired
Video shortcode HTML output.

Return

string HTML Output.

Source

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;
}

Changelog

VersionDescription
4.8.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.