YouTube oEmbed and privacy-enhanced mode

At the moment WordPress only recognises youtube.com/watch, youtube.com/playlist and youtu.be. However there is wp_oembed_add_provider; try something like

wp_oembed_add_provider(
    '#http://(www\.)?youtube-nocookie\.com/embed.*#i',
    'http://www.youtube-nocookie.com/oembed', true );

(untested sorry). You could even overwrite the existing providers to redirect to -nocookie and then use the video shortcode as normal. And you can do this with add_filter('oembed_providers', ... ); too if you’d prefer.

Leave a Comment