您可以使用快捷码控制嵌入式TED视频的大小:
[ted id="1650" width="300" height="200"]
如果要对其进行预定义,可以使用:
if(!isset($atts[\'width\'])){
$atts[\'width\']=600; // Default width
}
if(!isset($atts[\'height\'])){
$atts[\'height\']=400; // Default height
}
那么代码
here 将是:
// Whitelist the TEDTalks oEmbed URL
wp_oembed_add_provider( \'http://www.ted.com/talks/*\', \'http://www.ted.com/talks/oembed.json\' );
function ted_shortcode( $atts ) {
// We need to use the WP_Embed class instance
global $wp_embed;
// width:
if(!isset($atts[\'width\'])){
$atts[\'width\']=600; // Default width
}
// height:
if(!isset($atts[\'height\'])){
$atts[\'height\']=400; // Default height
}
// The "id" parameter is required
if ( empty($atts[\'id\']) )
return \'\';
// Construct the TEDTalk URL
$url = \'http://www.ted.com/talks/view/lang/eng/id/\' . $atts[\'id\'];
// Run the URL through the handler.
// This handler handles calling the oEmbed class
// and more importantly will also do the caching!
return $wp_embed->shortcode( $atts, $url );
}
add_shortcode( \'ted\', \'ted_shortcode\' );