Function:

mp_core_oembed_get()

Purpose:

Get oembed and set it to be 100% width and height.

Overview:

This function takes an oembed in WordPress and makes it fit at 100% into wherever it is being put. Since an iframe can’t be sized to 100%, it uses a 16×9 image beneath the video to size itself correctly and matches its size to that image.

Usage Example:

mp_core_oembed_get( $video_url, $min_width, $max_width );

Parameters:

$video_url (string) The URL of the Video (YouTube, Vimeo, etc. – See “Embeds” for WordPress for accepted types)

$min_width (integer) Optional. The minimum width in pixels this video should ever be.

$max_width (integer) Optional. The maximum width in pixels this video should ever be.

Returns:

$html_output (string) An iframe html tag containing the video wrapped in a div set to 100% width over a 16×9 image.