Created
March 7, 2019 16:22
-
-
Save fxmontigny/919d3a2741f6b64101fdad81e7ee6074 to your computer and use it in GitHub Desktop.
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
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