Filter oembeds tags to modify iframe attributes

By default, when putting another WP url inside a post/page, it oEmbeds it and produces a blockquote and iframe code with the default in the front-end: <iframe class=”wp-embedded-content” sandbox=”allow-scripts” security=”restricted” ….></iframe> It also produces an error in the JS console XMLHttpRequest cannot load http://example.com/wp-content/themes/themename/js/test.js. No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin ‘null’ … Read more

WordPress 5.3.x YouTube oEmbed is not working

We followed Brian Fegter’s answer to display YouTube videos using WordPress’ oEmbed feature: // Public video. $video_url=”https://www.youtube.com/watch?v=1lODe0i7dNw”; require_once(ABSPATH . ‘wp-includes/class-wp-oembed.php’); $oembed = new WP_oEmbed; // Auto-detect the video provider with the following $provider = $oembed->discover($video_url); $video = $oembed->fetch($provider, $video_url); echo $video->html; The code worked earlier. But right now it’s not working. We’re using WordPress 5.3.2. … Read more

Making oEmbed work on the excerpt field

How can I make oEmbed work on the excerpt field so I only have to paste the youtube url in there and then be able to echo ‘get_the_excerpt()’? I also want to filter oEmbed and change the wmode but I think I found a solution for that here: http://code.hyperspatial.com/all-code/wordpress-code/oembed-wmode/ EDIT: Crap! I was wrong, it … Read more

Hiding Comments Icon On oembed

I need to hide the comments icon on oEmbed widgets or disable the comments icon feature completely. I’ve been looking at the following links: https://developer.wordpress.org/reference/files/wp-includes/embed.php/ https://core.trac.wordpress.org/browser/tags/4.5/src/wp-includes/embed.php What I came up with after thinking for a while was this. I feel its a bit hacky, however it works. I copied the code from the_embed_site_title() and added … Read more

Remove frameborder attribute from iframes

The W3C Validator outputs an error because WordPress adds frameborder=”0″ to iframes. Also the Validator does not like the allow attribute. I found a similar question for Vimeo Videos: WordPress oEmbed W3C Validation. However, I couldn’t get it to work. That’s the code I added to the function.php file which however does not work: add_filter( … Read more