Hot answers tagged

11 votes
Accepted

How can I clear oEmbed caches for YouTube on posts as they are loaded

How to trigger an oembed cache regeneration The default cache time is 24 hours and we can adjust it with the oembed_ttl filter. But as you've noticed, expired cache is not enough to trigger a cache ...
birgire's user avatar
  • 66.6k
10 votes
Accepted

how to escape wp_oembed_get for phpcs

Note that the WPCS standards for PHPCS are not "official". I am one of the maintainers, and all that we can do is to do our best to match the standards that WordPress suggests. In this case, I'm ...
J.D.'s user avatar
  • 3,895
8 votes

Disable automatic oEmbed of a youtube url within the content

The accepted answer didn't work in my case. URLs were still being converted to embeds in the post editor. By looking at the source of wp-includes/class-wp-embed.php where this stuff is handled, I ...
Chris Montgomery's user avatar
7 votes
Accepted

What are the Oembed Links For?

Those are links for the wordpress "self" oEmbed. It provides the URLs needed to enable embeding the content of the wordpress site in other sites and they are resuired for oEmbed Discover You are ...
Mark Kaplun's user avatar
  • 23.2k
6 votes
Accepted

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( '...
Dave Romsey's user avatar
  • 17.6k
6 votes
Accepted

How to use oEmbeds on Post Content during AJAX requests

Actually this was quite easy – when you know what's missing: The current post ID for the global $wp_embed object, so it knows what to refer to. The reason is simple: oEmbeds get cached as post meta ...
kaiser's user avatar
  • 50.4k
6 votes
Accepted

Remove frameborder attribute from iframes

WordPress doesn't add the frameborder attribute. YouTube does. It's part of their embed code. If you absolutely must remove it you can use the embed_oembed_html filter to modify the returned HTML: ...
Jacob Peattie's user avatar
4 votes

Adding a wrapper to the youtube embed automatically?

Personally, I found the oembed_dataparse filter pretty fiddly to use; sometimes it worked, sometimes it didn't; and when used in conjunction with custom TinyMCE instances, it seems as though the added ...
indextwo's user avatar
  • 431
4 votes

Add parameters vimeo videos using wordpress embeds

There are several filters in WordPress for altering oEmbed data, depending on when you need to modify the results: embed_handler_html Filters the returned embed handler. embed_oembed_html Filters the ...
rjb's user avatar
  • 1,347
4 votes
Accepted

Disable automatic oEmbed of a youtube url within the content

disable the oembed like below in functions.php : remove_filter( 'the_content', array( $GLOBALS['wp_embed'], 'autoembed' ), 8 ); Thanks!
jas's user avatar
  • 1,487
4 votes
Accepted

Hiding Comments Icon On oembed

Pretty sure you can just remove them entirely: remove_action( 'embed_content_meta', 'print_embed_comments_button' );
TheDeadMedic's user avatar
  • 36.2k
3 votes
Accepted

Disable oEmbed for a Single Shortcode or at Least All Internal Links

Here we consider the question: can post embeds be disabled for all the internal links on a site currently running WordPress 4.5.3? The Short Story If we want to disable post embedding of internal ...
birgire's user avatar
  • 66.6k
3 votes

WordPress, oEmbed & YouTube video's with a 'dash'

Turns out the YouTube video in question had Embedding disabled by request. Tested with other YouTube videos with a 'dash' and they work fine (if embedding is not disabled).
David Clough's user avatar
3 votes
Accepted

Correct regex for wp_embed_register_handler

Just few notes here: We have to be careful using % within sprintf() to avoid confusion with the placeholders. Try to remove the CSS styles. It's sometimes easier to use the # or ~ delimiters in ...
birgire's user avatar
  • 66.6k
3 votes
Accepted

How to add new embed handler not supported by oembed

Registering a custom embed handler Here's an example how we can use the wp_embed_register_handler() function in your case: /** * Register an embed handler for myvi videos */ add_action( 'init', ...
birgire's user avatar
  • 66.6k
3 votes
Accepted

How to check If Oembed is empty or not

The wp_oembed_get() only works for supported oEmbed providers. The return value is also is a URL of false, as mentioned per codex: If $url is a valid url to a supported provider, the function ...
Johansson's user avatar
  • 15.1k
3 votes
Accepted

Filter oembeds tags to modify iframe attributes

I was able to solve the the CORS issue by using this snippet which now allows this iFrame to allow-same-origin or runs scripts inside this domain. function oembed_iframe_overrides($html, $url, $attr) ...
Carl Alberto's user avatar
  • 1,037
3 votes
Accepted

Can I use wp_oembed_get to detect a valid embeddable link or is there a better way to do so?

The regex patterns for matching embeddable URLs are stored in WP_oEmbed, which has the method get_provider() for checking if a given URL is an embeddable URL for a supported provider. Just set the ...
Jacob Peattie's user avatar
2 votes

WP Oembed not passing through the "autoplay=1" variable

Cross-posting my answer from https://stackoverflow.com/a/55053642/799327, hope that's okay since it's from the same OP: So, after some research on this, the best way to do this is to leverage the ...
Laust Deleuran's user avatar
2 votes
Accepted

Manipulating oembed_dataparse stopped working for YouTube embeds

I think I solved by doing this: add_filter('oembed_dataparse', 'bolster_oembed_filter', 0, 2 ); I changed the priority of the add_filter statement to 0, now it works again.
Florian's user avatar
  • 1,575
2 votes

Video Embed with Captions in Turkish

Okay the thing is that the oembed endpoint seems not to support any other than the default parameters. So it seems that all you can do is parse the response and add in your parameters to the iframe ...
kraftner's user avatar
  • 5,590
2 votes
Accepted

Getting results from wp_oembed_add_provider

Ok I managed to solve this! Did some digging through how the embed system works, and it turns out it wasn't the use of wp_oembed_add_provider() that was wrong. Debugging autoembed_callback() in wp-...
Tim Malone's user avatar
  • 4,664
2 votes
Accepted

wp_embed_register_handler is not working

You are trying to match the r2jeim68kuq6.html part, but you're not allowing dots in your regex pattern here: '#https://vidoza\.net/([a-zA-Z0-9_-]+)$#i' You can try e.g. (removing the A-Z too because ...
birgire's user avatar
  • 66.6k
2 votes
Accepted

wp_embed_register_handler to embed html files

Fixing the regex pattern To match an url of the type: https://coptic-treasures.com/ {Some string with a mix of a-z letters and hyphen}/{Some number}.html like this example: https://coptic-...
birgire's user avatar
  • 66.6k
2 votes
Accepted

Instagram URL is converted into oEmbed

Figured it out. Embed shortcode stores the oemebd data as post meta using md5 hash. wp-includes/class-wp-embed.php // Check for a cached result (stored in the post meta) $key_suffix = md5( $url . ...
Manoj H L's user avatar
  • 135
2 votes
Accepted

WordPress 5.3.x YouTube oEmbed is not working

So apparently the issue also happens in WordPress 5.6 (the latest release as of writing), and YouTube is probably at fault because the (oEmbed) <link> tags are in the body instead of the head (...
Sally CJ's user avatar
  • 37.3k
2 votes

oembed_cache SPAM problem

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 ...
Medium_D's user avatar
1 vote
Accepted

Add field to dashboard to update embedded URL on homepage?

Add the below code in the functions.php file and it will create a text field in the general setting options page add_action('admin_init', 'embed_url_initialize'); function embed_url_initialize() { ...
Lovin Nagi's user avatar
1 vote
Accepted

Checkbox on a meta box using CMB2 Plugin

If i get it right, then you just need to get that value from post meta, and make condition. $image_or_video = get_post_meta($post_id, $prefix . 'image_or_video', true); // Option 2 is selected if( '...
PayteR's user avatar
  • 206
1 vote
Accepted

Responsive embed for the video shortcode

You could create a new callback for the embed_oembed_html filter and target the third input argument, the oembed $url. Then you could e.g. create boolean helper functions like (untested): function ...
birgire's user avatar
  • 66.6k

Only top scored, non community-wiki answers of a minimum length are eligible