Created
June 24, 2013 19:54
-
-
Save Otto42/5853020 to your computer and use it in GitHub Desktop.
mlb.tv embed code for a WordPress plugin
This file contains 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 | |
function mlbtv_embed_register_handler() { | |
wp_embed_register_handler( 'mlbtv', '|https?://wapc.mlb.com/play/\?content_id=([0-9]*)?#?|i', 'mlbtv_embed_handler' ); | |
} | |
add_action( 'init', 'mlbtv_embed_register_handler' ); | |
function mlbtv_embed_handler( $matches, $attr, $url, $rawattr ) { | |
if ( !empty($rawattr['width']) && !empty($rawattr['height']) ) { | |
$width = (int) $rawattr['width']; | |
$height = (int) $rawattr['height']; | |
} else { | |
list( $width, $height ) = wp_expand_dimensions( 400, 224, $attr['width'], $attr['height'] ); | |
} | |
return "<iframe src='http://wapc.mlb.com/shared/video/embed/embed.html?content_id={$matches[1]}&width={$width}&height={$height}&property=mlb' width='{$width}' height='{$height}' frameborder='0'>Your browser does not support iframes.</iframe>"; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thank you very useful
but if you can explain for me how i can add support embed handler for facebook videos and posts?