Created
March 21, 2018 03:28
-
-
Save patric-boehner/827d6f9381a08cf5e7ffc02a76b39d02 to your computer and use it in GitHub Desktop.
Add oEmbed support for Google Drive Video
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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