Created
November 20, 2014 23:35
-
-
Save macedd/4c8e962b898eaa06fde0 to your computer and use it in GitHub Desktop.
magnificPopup to allow youtube playlists and embeded videos
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.extend(true, $.magnificPopup.defaults, { | |
// Allow embed youtube (playlist, etc) | |
iframe: { | |
patterns: { | |
youtube: { | |
index: 'youtube.com', | |
id: function(src) | |
{ | |
// link pattern | |
var mt = src.match(/v=([^&]+)(&(.*))?/); | |
if (mt) | |
return mt[1] +'?'+ mt[3]; | |
// embed pattern | |
mt = src.match(/embed\/([^\?\/]+)(\?(.*))?/); | |
if (mt) | |
return mt[1] +'?'+ mt[3]; | |
}, | |
src: '//www.youtube.com/embed/%id%&autoplay=1&rel=0' | |
} | |
} | |
}, | |
// When elemened is focused, some mobile browsers in some cases zoom in | |
// It looks not nice, so we disable it: | |
callbacks: { | |
beforeOpen: function() { | |
if ($(window).width() < 700) | |
this.st.focus = false; | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks a lot for this solution. It really helped me!