• I have some code in functions.php which adds options to my YT links. I want the same for my soundcloud. Is there any way to control this from functions.php? And if possible move adding video-frame only for YT videos.

    Also soundcloud doesn’t embed without including it in functions. Is it normal?

    function Oembed_youtube_no_title($html,$url,$args){
        $url_string = parse_url($url, PHP_URL_QUERY);
        parse_str($url_string, $id);
        if (isset($id['v'])) {
            return '<iframe width="100%" height="100%" src="http://www.youtube.com/embed/'.$id['v'].'?rel=0&theme=light&showinfo=0&iv_load_policy=3&vq=hd720" frameborder="0" allowfullscreen></iframe>';
        }
        return $html;
    }
    add_filter('oembed_result','Oembed_youtube_no_title',10,3);
    
    function alx_embed_html( $html ) {
        return '<div class="video-frame">' . $html . '</div>';
    }
    add_filter( 'embed_oembed_html', 'alx_embed_html', 10, 3 );
    add_filter( 'video_embed_html', 'alx_embed_html' ); // Jetpack
    
    function add_oembed_soundcloud(){
    wp_oembed_add_provider( 'http://soundcloud.com/*', 'http://soundcloud.com/oembed' );
    }
    add_action('init','add_oembed_soundcloud');
Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    You can alter the HTML output of any Oembed object with the ‘oembed_result’ filter. When you have different embedded players, it’s important to have your code distinguish between the players before attempting to alter the HTML. You don’t want to apply YT parameters to a soundcloud player. Doing so is really just a matter of basic string search and replace operations. Sometimes using regexp is useful for making the proper string matches.

    In a similar manner, you can only apply a video frame to YT videos by identifying “youtube.com” in the HTML before applying the frame. This should be fine as long you don’t encounter any audio files named “youtube.com.mp3” or similar.

    You shouldn’t need to add soundcloud as a provider, it is part of the default provider list. I have no idea why you need to add it, unless some other process had removed it for some reason.

Viewing 1 replies (of 1 total)

The topic ‘Soundcloud embed options’ is closed to new replies.