Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: oEmbed for BuddyPress plugin – out now!


levin
Participant

@levinng

Hi, I just added a embed provider like the following code in theme functions.php, it can work with blog post, but not the activity stream, I tried to add mytube.com in the whitelist but still doesnt’ work. Is there i’ve something missing?

I’m using WPMU 2.9.1.1 and BP 1.2.1

Thanks so much for your help

<?php

function wp_embed_handler_mytube( $matches, $attr, $url, $rawattr ) {

// If the user supplied a fixed width AND height, use it

if ( !empty($rawattr[‘width’]) && !empty($rawattr[‘height’]) ) {

$width = (int) $rawattr[‘width’];

$height = (int) $rawattr[‘height’];

} else {

list( $width, $height ) = wp_expand_dimensions( 640, 360, $attr[‘width’], $attr[‘height’] );

}

return apply_filters( ’embed_mytube’, ‘<object height=”‘ . esc_attr($height) . ‘” width=”‘ . esc_attr($width) . ‘” ><param value=”http://www.my-tube.com/em?v=&#8217; . esc_attr($matches[1]) . ‘” name=”movie”></param><embed src=”http://www.my-tube.com/em?v=&#8217; . esc_attr($matches[1]) . ‘” allowfullscreen=”true” width=”‘ . esc_attr($width) . ‘” height=”‘ . esc_attr($height) . ‘” align=”middle” allowScriptAccess=”always” type=”application/x-shockwave-flash”></embed></object>’, $matches, $attr, $url, $rawattr );

}

function register_embed_handlers() {

wp_embed_register_handler( ‘mytube’, ‘#http://www.my-tube.com/v\?v=([A-Za-z0-9]{0,50})#i’, ‘wp_embed_handler_mytube’ );

}

add_action(‘wp’, ‘register_embed_handlers’);

?>

Skip to toolbar