Add wrapper to only youtube videos via embed_oembed_html filter function

$url will contain the full URL to the embed source. E.g.: https://www.youtube.com/watch?v=_UmOY6ek_Y4, so you have to search within $url to see if the provider’s name appears: add_filter( ’embed_oembed_html’, ‘wpse_embed_oembed_html’, 99, 4 ); function wpse_embed_oembed_html( $cache, $url, $attr, $post_ID ) { $classes = array(); // Add these classes to all embeds. $classes_all = array( ‘responsive-container’, ); … Read more

Changing Oembed max width based type of page

Using the following in your functions.php file should do the trick: /** * Configure default oEmbed video sizes */ function base_oembed_defaults($embed_size) { if( is_single() ) { $embed_size[‘width’] = 580; $embed_size[‘height’] = 435; } return $embed_size; } add_filter(’embed_defaults’, ‘base_oembed_defaults’); Add as many WordPress conditional statements as you like to match the desired aspect ratio for each … Read more

Fallback for oEmbed content

Probably impractical. When you do not control the content you can not know if it will be embedable at the time of viewing. Easiest example of why it might be hard in the context of youtube/vimeo is videos that can become restricted, either private or geo restricted. In that case the content is still embedable … Read more

Modify youtube video size on one page and show another size on different page

I’m assuming you are using WordPress’ Embeds feature. Generally speaking wp_embed_defaults() gives you the information you need. A look at the source discloses the possibilities you have: 2017 /** 2018 * Create default array of embed parameters. 2019 * 2020 * The width defaults to the content width as specified by the theme. If the … Read more

Markup of oEmbed codes in the editor?

I think this might be a step in the right direction: http://codex.wordpress.org/Plugin_API/Filter_Reference Specifically the the_editor_content filter which is “applied to post content before putting it into a rich editor window.” Sorry I can’t flesh it out more for you but I am just starting to play around with filters myself and have miles to go … Read more