Takes a URL and Attempts to fetch the embed HTML for it using oEmbed.
<?php $embed_code = wp_oembed_get( $url, $args ); ?>
Available arguments:
NOTE: above it says "no default" but that relates to the $args variable passed in. Internally it retrieves some default values conditionally based on site settings.
If you do not pass in a width argument, then the function will check for a content_width setting, and a media settings max width. If neither of those are set, and you don't pass in your own width, the used width will be '500'. If one of those values is set, it'll use that set value.
If you do not pass in a height argument, then the function will check for a media settings max height, and if there is nothing there either, it will use '700'.
Retrieve the embed code for a URL from a supported oEmbed provider:
<?php $embed_code = wp_oembed_get('http://www.youtube.com/watch?v=AbcDeFg123'); ?>
Retrieve the embed code for a URL from a supported oEmbed provider - with width argument:
<?php $embed_code = wp_oembed_get('http://www.youtube.com/watch?v=AbcDeFg123', array('width'=>400)); ?>
wp_oembed_get() is located in wp-includes/embed.php
.
Since: 2.9.0
Embeds: wp_oembed_add_provider(), wp_oembed_remove_provider(), wp_oembed_get(), wp_embed_defaults(), wp_embed_register_handler(), wp_embed_unregister_handler(), get_embedded_audio(), get_embedded_media(), get_embedded_video(), wp_embed_handler_audio(), wp_embed_handler_video()