Skip to content

Instantly share code, notes, and snippets.

@MrVibe
Created January 13, 2021 06:27
Show Gist options
  • Save MrVibe/d06d072f82edfb499b4684db439f2af7 to your computer and use it in GitHub Desktop.
Save MrVibe/d06d072f82edfb499b4684db439f2af7 to your computer and use it in GitHub Desktop.
Youtube Preview video in profile. Field ID 51 , add this in WP Admin - WPLMS - footer - google analytics code
<script>
if(document.querySelector('.vibebp_profile_field.field_51')){
new Promise(function(resolve){
let youtube_url = document.querySelector('.vibebp_profile_field.field_51 > div').textContent;
let ycode = youtube_url.match(/v=([^&#]{5,})/);
var mdiv = document.createElement('div');
mdiv.setAttribute('id','field_51_youtube');
mdiv.setAttribute('data-plyr-provider','youtube');
mdiv.setAttribute('data-plyr-embed-id',ycode[1]);
document.querySelector('.vibebp_profile_field.field_51 > div').remove();
document.querySelector('.vibebp_profile_field.field_51').appendChild(mdiv);
resolve();
}).then(function(){
new Plyr('#field_51_youtube');
});
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment