Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save fxmontigny/919d3a2741f6b64101fdad81e7ee6074 to your computer and use it in GitHub Desktop.
Save fxmontigny/919d3a2741f6b64101fdad81e7ee6074 to your computer and use it in GitHub Desktop.
jQuery(document).ready(function() {
jQuery('video').each(function() {
const sourceDom = jQuery(this).find('source');
if(sourceDom.length === 1) {
const src = jQuery(sourceDom[0]).attr('src'),
indexVimeo = src.indexOf('vimeo.com');
if(indexVimeo !== -1) {
const split = src.split('/')
const iframe = document.createElement('iframe'),
iframeJquery = jQuery(iframe);
iframeJquery.attr('src', 'https://player.vimeo.com/video/' + split[split.length - 1] + '?autoplay=1&title=0&byline=0&portrait=0');
iframeJquery.attr('frameborder', '0');
iframeJquery.attr('webkitallowfullscreen', '');
iframeJquery.attr('mozallowfullscreen', '');
iframeJquery.attr('allowfullscreen', '');
iframeJquery.attr('class', 'custom-vimeo-player');
iframeJquery.insertBefore(this);
this.remove();
}
}
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment