Viewing 2 replies - 1 through 2 (of 2 total)
  • Have you tried looking for a suitable plugin?

    Thread Starter zzuum

    (@zzuum)

    I found the way.. thank you…

    $thumb = get_youtube_thumb( 'http://www.youtube.com/watch?v=OC2TTslf_YM' );
    $Idvid = get_youtube_thumb( 'OC2TTslf_YM' );  
    
    echo '<img  src="http://img.youtube.com/vi/'.$Idvid.'/default.jpg">';
    function get_youtube_thumb( $video_id )
    {
    
        // Did we get a URL?
        if ( FALSE !== filter_var( $video_id, FILTER_VALIDATE_URL ) )
        {
    
            // http://www.youtube.com/v/abcxyz123
            if ( FALSE !== strpos( $video_id, '/v/' ) )
            {
                list( , $video_id ) = explode( '/v/', $video_id );
            }
    
            // http://www.youtube.com/watch?v=abcxyz123
            else
            {
                $video_query = parse_url( $video_id, PHP_URL_QUERY );
                parse_str( $video_query, $video_params );
                $video_id = $video_params['v'];
            }
    
        }
    
        return 'http://img.youtube.com/vi/' . $video_id . '/default.jpg';
    
    }

    No i want to search in post for youtube utl.. 🙂

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Youtube video thubnail’ is closed to new replies.