Skip to content

Instantly share code, notes, and snippets.

@timersys
Created July 31, 2017 16:57
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 timersys/d3cde5a27e9f2ae4ac83d5c619e6ebfa to your computer and use it in GitHub Desktop.
Save timersys/d3cde5a27e9f2ae4ac83d5c619e6ebfa to your computer and use it in GitHub Desktop.
Videos on Popups plugin
/**
* Snippet for WordPress popup plugin
* https://wordpress.org/plugins/popups/
* Add this in your theme javascript files
*/
/**
* How to pause videos when popup is closed
* Replace 123 with your popup id
*/
jQuery(document).on('spu.box_close',function(e,id){
if( id == '123' ) {
$('#spu-123').remove(); // this will destroy popup entirely
// $('#video-id').remove(); // or you can target your video container and leave popup intact
}
});
/**
* How to play video when popup is open
* Replace 123 with your popup id
*/
jQuery(document).on('spu.box_open',function(e,id){
if( id == '123' ) {
$('#spu-123 .spu-box-content').html('<iframe src="video_url"></iframe>'); // try loading the video iframe once the popup is opened
// Or use youtube api as described in https://gist.github.com/timersys/99db1a8d2c8db74cb954
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment