Last active
December 15, 2015 05:39
-
-
Save kbjr/5210793 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
<?php while (have_posts()) : the_post(); $count++; ?> | |
<?php $video = get_field('video'); ?> | |
<a href="#" onclick="switchVideo(this, '<?php echo $video; ?>'); return false;" class="vidtn"> | |
<img src="<?php echo the_field('vidthumbnail'); ?>" /> | |
</a> | |
<?php endwhile; ?> | |
<script type="text/javascript"> | |
// | |
// @param original the DOM element of the existing video to be replaced | |
// @param newVideo the video that we are inserting in place of the original | |
// @return jQuery a jQuery object containing the new video element | |
// | |
function switchVideo(original, newVideo) { | |
var $newElem = $('<iframe width="853" height="480" src="http://www.youtube.com/embed/' + newVideo + | |
'?rel=0" frameborder="0" allowfullscreen></iframe>'); | |
$newElem.replaceAll(original); | |
return $newElem; | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment