YouTube Channel
Making use of WP oEmbed (1 post)

  1. samface
    Posted 3 years ago #

    This is a slight modification of the code for displaying html5 iframes to trigger the WP oEmbed hook. Just replace the lines 273 to 275 of youtube-channel.php with the following:

    $attr['discover'] = (apply_filters('embed_oembed_discover', false)) ? true : false;
    $oembed_html = wp_oembed_get("http://www.youtube.com/watch?v=".$yt_url, $attr);
    // If there was a result, oembed the link
    if ($oembed_html) {
    echo apply_filters('embed_oembed_html', $oembed_html, "http://www.youtube.com/watch?v=".$yt_url, $attr);
    } else {
    <iframe title="YouTube video player" width="<?php echo $width; ?>" height="<?php echo $height; ?>" src="http://www.youtube.com/embed/<?php echo $yt_url."?wmode=opaque&enablejsapi=1"; if ( $controls ) { echo "&controls=0"; } if ( $hideinfo ) { echo "&showinfo=0"; } if ( $autoplay ) { echo "&autoplay=1"; } if ( $hideanno ) { echo "&iv_load_policy=3"; } if ( $themelight ) { echo "&theme=light"; } ?>" frameborder="0" allowfullscreen id="<?php echo $ytc_vid ?>"></iframe>

    This allows user defined functions to hook into the embed html. In my case I needed to strip the iframe width and height to make it work with a responsive design. This is not an ugly "hack", it's just enabling a standard hook of WP-core. I would suggest adding this to the next update. :)


Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic