WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Youtube video thubnail (3 posts)

  1. zzuum
    Member
    Posted 7 months ago #

    Hello,
    I need to get Thubnail from youtube video embed code from post..

    Thank you ..

  2. esmi
    Forum Moderator
    Posted 7 months ago #

    Have you tried looking for a suitable plugin?

  3. zzuum
    Member
    Posted 7 months ago #

    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.. :)

Reply

You must log in to post.

About this Topic