Skip to content

Instantly share code, notes, and snippets.

@gjjones
Created July 11, 2017 20:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gjjones/7cbbe194dc58889449d83d05ee6459c9 to your computer and use it in GitHub Desktop.
Save gjjones/7cbbe194dc58889449d83d05ee6459c9 to your computer and use it in GitHub Desktop.
Dealing with oEmbed
require_once( ABSPATH . 'wp-includes/class-oembed.php' );
$WP_oEmbed = new WP_oEmbed();
$data = $WP_oEmbed->get_data( $video_url );
$thumbnail_url = $data->thumbnail_url;
// to be stored in data attribute until needed
$lightbox_markup = htmlentities( $WP_oEmbed->data2html( $data, $video_url), ENT_QUOTES );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment