FACEPALM!

By: TheThinkingAtheist

5251   100   170450

Uploaded on 01/30/2014

It's a crazy world out there. And sometimes, there's only one appropriate response.

Comments (2):

By anonymous    2017-09-20

I'd be inclined to simply grab the video ID per this question and use it to formulate your embed markup as you like.

http://jsfiddle.net/isherwood/cH6e8/

function getId(url) {
    var regExp = /^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=)([^#\&\?]*).*/;
    var match = url.match(regExp);

    if (match && match[2].length == 11) {
        return match[2];
    } else {
        return 'error';
    }
}

var videoId = getId('http://www.youtube.com/watch?v=zbYf5_S7oJo');

var iframeMarkup = '<iframe width="560" height="315" src="//www.youtube.com/embed/' 
    + videoId + '" frameborder="0" allowfullscreen></iframe>';

Here's a more elaborate demo.

Original Thread

Popular Videos 234

Submit Your Video

If you have some great dev videos to share, please fill out this form.