$(".popup-video").magnificPopup({
type: "iframe",
mainClass: "mfp-fade",
removalDelay: 160,
preloader: false,
fixedContentPos: false,
// your default config here
// All below settings are default except the rel attribute in youtube-src
// This is here to remove the related videos from showing up after the video ends
// Adding rel=0 from url in html template stopped autoplay, hence this hack
iframe: {
// markup:
// '<div class="mfp-iframe-scaler">' +
// '<div class="mfp-close"></div>' +
// '<iframe class="mfp-iframe" frameborder="0" allowfullscreen></iframe>' +
// "</div>", // HTML markup of popup, `mfp-close` will be replaced by the close button
patterns: {
youtube: {
index: "youtube.com/", // String that detects type of video (in this case YouTube). Simply via url.indexOf(index).
id: "v=", // String that splits URL in a two parts, second part should be %id%
// Or null - full URL will be returned
// Or a function that should return %id%, for example:
// id: function(url) { return 'parsed id'; }
src: "//www.youtube.com/embed/%id%?autoplay=1&rel=0" // URL that will be set as a source for iframe.
}
}
}
});