Problems using WP’s oembed function + Instagram + AJAX

Instagram has changed its embed code from being just an iframe to a bunch of HTML and a JS script. Very inelegant, but nothing we can do. This setup, of course, fails when called through AJAX since the JS file that’s part of the HTML does not run. Thankfully there is another official way to … 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

How to change default width parameter of embedded video in wordpress?

if you could make it to something like this: <div class=”videoWrapper”> <iframe width=”600″ height=”338″ src=”https://www.youtube.com/embed/f5CcOq8UzkI?feature=oembed” frameborder=”0″ allowfullscreen=””></iframe> </div> then responsive css for that would be like this: .videoWrapper { position: relative; padding-bottom: 56.25%; /* 16:9 */ padding-top: 25px; height: 0; } .videoWrapper iframe { position: absolute; top: 0; left: 0; width: 100%; height: 100%; } … Read more

When oEmbed fails, display an alternative

I think the best thing to do in this case is to wrap your oEmbed content with a div before they are rendered and then show an alternate image with the CSS background-image property. If the video loads, then the oEmbed content will cover the background image. You can add the wrapper using the embed_oembed_html … Read more