Skip to content

Instantly share code, notes, and snippets.

@marcelo2605
Created March 12, 2021 11:57
Show Gist options
  • Save marcelo2605/24ee8e6cf4b254694a388750eb430a7a to your computer and use it in GitHub Desktop.
Save marcelo2605/24ee8e6cf4b254694a388750eb430a7a to your computer and use it in GitHub Desktop.
Use Lite YouTube in WordPress
/**
* Use Lite YouTube in posts embeds
* https://github.com/paulirish/lite-youtube-embed
*/
add_filter('embed_oembed_html', function($cached_html, $url, $attr, $post_id) {
$querystring = parse_url($url, PHP_URL_QUERY);
parse_str($querystring, $params);
if (isset($params['v'])) {
$format = '<lite-youtube videoid="%s"></lite-youtube>';
$cached_html = sprintf($format, $params['v']);
}
return $cached_html;
}, 99, 4);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment