Created
March 4, 2022 19:51
-
-
Save khleomix/228f43ca5bba9acecb7f410798396c9a to your computer and use it in GitHub Desktop.
Wistia Background Video
This file contains hidden or 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
<?php | |
/** | |
* MODULE - Wistia Player. | |
* | |
* Autoplay nuted Wistia Video in the background and remove from DOM when done. | |
*/ | |
/** | |
* Accepts 'class','wistia_id'. | |
*/ | |
$defaults = [ | |
'class' => [ 'module-wistia', 'wistia', 'video-embed' ], | |
'wistia_id' => false, | |
]; | |
$args = return_formatted_args( $args, $defaults ); | |
?> | |
<?php if ( $args['wistia_id'] ) : ?> | |
<div id="wistia-<?php echo esc_attr( $args['wistia_id'] ); ?>"> | |
<div class="background-wrapper"> | |
<iframe src="//fast.wistia.com/embed/iframe/<?php echo esc_attr( $args['wistia_id'] ); ?>?videoFoam=true&autoPlay=true&muted=true&controlsVisibleOnLoad=false&&wmode=transparent" allowtransparency="true" frameborder="0" scrolling="no" class="wistia_embed" id="hero-video" name="wistia_embed"></iframe> | |
<script src="//fast.wistia.com/assets/external/E-v1.js"></script> | |
</div><!-- .background-wrapper --> | |
</div><!-- #wistia-{*} --> | |
<?php | |
endif; |
This file contains hidden or 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
/** | |
* File wistia.js | |
* | |
* Deal with background wistia video playback. | |
*/ | |
( function () { | |
// grab Wista API | |
const wistiaEmbed = document.getElementById( 'hero-video' ).wistiaApi; | |
// when the video has finished playing, remove . | |
wistiaEmbed.bind( 'end', function () { | |
wistiaEmbed.remove(); | |
} ); | |
} )(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment