Search code examples
jqueryiframeyoutubesame-origin-policymagnific-popup

magnific popup: how to add support for youtu.be shortened links


With links like http://youtu.be/1wAlbzKoYbs I am getting this error:

Refused to display 'http://www.youtube.com/watch?v=1wAlbzKoYbs&feature=youtu.be' 
in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN'.

Is there a way to fix that?

Links like http://www.youtube.com/watch?v=1wAlbzKoYbs works.

http://jsfiddle.net/6vheh/1/


Solution

  • This is easier than I thought:)

            iframe: {
                patterns: {
                    youtube_short: {
                      index: 'youtu.be/',
                      id: 'youtu.be/',
                      src: '//www.youtube.com/embed/%id%?autoplay=1'
                    }
                }
            }
    

    http://jsfiddle.net/6vheh/2/