Created
January 13, 2021 06:27
-
-
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
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
<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