Skip to content

Instantly share code, notes, and snippets.

@patric-boehner
Created March 21, 2018 03:28
Show Gist options
  • Save patric-boehner/827d6f9381a08cf5e7ffc02a76b39d02 to your computer and use it in GitHub Desktop.
Save patric-boehner/827d6f9381a08cf5e7ffc02a76b39d02 to your computer and use it in GitHub Desktop.
Add oEmbed support for Google Drive Video
<?php
// Add oEmebed support for Google Drive Video
wp_embed_register_handler(
'google-drive-videos',
'#https?://drive.google\.com/file/d/([a-zA-Z0-9_-]+)/preview$#i',
'pb_add_oembed_handler_dgvideo'
);
function pb_add_oembed_handler_dgvideo( $matches, $attr, $url, $rawattr ) {
$embed = sprintf(
'<iframe src="https://drive.google.com/file/d/%1$s/preview" width="640" height="480"></iframe>',
esc_attr($matches[1])
);
return $embed;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment