Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save celticwebdesign/8083354408547b956ee7782d8c656e99 to your computer and use it in GitHub Desktop.
Save celticwebdesign/8083354408547b956ee7782d8c656e99 to your computer and use it in GitHub Desktop.
<?php
$local_folder = get_field('video_folder');
$path = "/var/sites/k/XXX.co.uk/public_html/Videos/top-video-folder/".$local_folder;
$files = scandir($path);
foreach ($files as &$value) {
if ($value != "." && $value != "..") {
if( end( explode(".",$value) ) == "mp4" ) {
echo "
<div class='single-video'>";
$pos = strpos( $value, '.mp4' );
if( $pos > 0 ) {
$title = substr( $value, 0, $pos);
}
$file = "/var/sites/k/XXX.co.uk/public_html/Videos/top-video-folder/".$local_folder.$title.".jpg";
if (file_exists($file)) {
$poster = "/Videos/top-video-folder/".$local_folder.$title.".jpg";
} else {
$poster = get_template_directory_uri()."/images/video-placeholder.png";
}
// <video autoplay loop muted playsinline preload poster='58653'>
echo "<video controls style='width: 100%;' poster='".$poster."'>
<source src='/Videos/top-video-folder/".$local_folder."/".$value."' type='video/mp4'></source>
</video>
<br />
<h3>".$title."</h3>";
echo "
</div>
";
}
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment