How to make enqueue_embed_scripts work with the embed_template filter
It turns out that I just overlooked adding the do_action( ’embed_head’ ) and do_action( ’embed_footer’ ) in the template file that I have. Teehee!
It turns out that I just overlooked adding the do_action( ’embed_head’ ) and do_action( ’embed_footer’ ) in the template file that I have. Teehee!
Add title attribute to oEmbed iframe for accessibility
Such happens when video is not publicly accessible. In my case the video was simply removed from YouTube by their author and ACF’s oEmbed module was unable to get metadata to properly display video.
This works, just don’t know if it’s the proper way to do it: Yes, the functions are the same so they’re equivalent. There is nothing wrong here. But if we dig a bit deeper, we see they’re not 2 filters for the same thing at all: embed_oembed_html filters the cached oEmbed HTML. oembed_result filters the … Read more
Because print_r prints a readable version of your variable $media, which will be an array as per the documentation for get_media_embedded_in_content(). You see Array ( [0] => [youtube embed] ) in your browser because it’s rendering the HTML of the array element – if you check the source code of your page you would see … Read more
I’m not sure why that’s not working except maybe you need to put the returned stuff in a variable? This is what works for me when I put it in my functions.php file: add_filter( ’embed_oembed_html’, ‘tdd_oembed_filter’, 10, 4 ) ; function tdd_oembed_filter($html, $url, $attr, $post_ID) { $return = ‘<figure class=”video-container”>’.$html.'</figure>’; return $return; }
Thank you so much for your reply. It helped me figure out what’s going on. I get a far bit of spam submissions via my contact form, these spam submissions include URLs. Although they are being flagged as spam and filtered out, WordPress still creates an oembed_cache entry in the database for them. I have … Read more
You’re probably best off using echo apply_filters( ‘the_content’, html_entity_decode( $monster_tiny_1 ) ); instead of echo wpautop(html_entity_decode($monster_tiny_1)); and similar, which will run the autoembed behavior.
Something like this should do the trick and force rel=0 for all YouTube oembed results. add_filter(‘oembed_dataparse’,’youtube_force_rel’,10,3); function youtube_force_rel($return, $data, $url) { if ($data->provider_name == ‘YouTube’) { return str_replace(‘feature=oembed’, ‘feature=oembed&rel=0’, $return); } else { return $return; } }
Check out the embed API, particularly the functions wp_oembed_add_provider() and wp_embed_register_handler(). What version of WP are you running at the moment? And what happens when you place a Twitter URL on its own line in plain text? 3.4+ should handle embeds, never tried it myself.