Skip to content

Instantly share code, notes, and snippets.

@jonathanheilmann
Last active August 9, 2017 08:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jonathanheilmann/5cf63a9b92eb63d602b6be0525d2181d to your computer and use it in GitHub Desktop.
Save jonathanheilmann/5cf63a9b92eb63d602b6be0525d2181d to your computer and use it in GitHub Desktop.
Add some more youtube patterns to EXT:jh_mangificpopup
page.jsFooterInline.10910 = TEXT
page.jsFooterInline.10910.value (
;(function($){
$(document).ready(function(){
$.extend(true, $.magnificPopup.defaults, {
iframe: {
patterns: {
youtube: {
index: 'youtube.com/',
id: function(embedSrc) {
var id;
if (embedSrc.indexOf('v=') !== -1) {
id = 'v=';
embedSrc = embedSrc.substr(embedSrc.lastIndexOf(id)+id.length, embedSrc.length).replace('&', '?');
embedSrc += (embedSrc.indexOf('?') !== -1 ? '&' : '?') + 'autoplay=1';
} else if (embedSrc.indexOf('/embed/') !== -1) {
id = '/embed/';
embedSrc = embedSrc.substr(embedSrc.lastIndexOf(id)+id.length, embedSrc.length);
embedSrc += (embedSrc.indexOf('?') !== -1 ? '&' : '?') + 'autoplay=1';
}
return embedSrc;
},
src: '//www.youtube.com/embed/%id%'
},
youtu_be: {
index: 'youtu.be/',
id: function(embedSrc) {
embedSrc = embedSrc.substr(embedSrc.lastIndexOf('/')+1, embedSrc.length);
embedSrc += (embedSrc.indexOf('?') !== -1 ? '&' : '?') + 'autoplay=1';
return embedSrc;
},
src: '//www.youtube.com/embed/%id%'
}
}
}
});
});
})(window.jQuery || window.Zepto);
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment