Tagged with " youtube"
Nov 16, 2012 - WordPress    Comments Off on Video Wall Page Template

Video Wall Page Template

This goes into the top of the template. You could put it in a plugin, but then it loads everywhere, so…

<?php
/*
Template Name: Video Wall Page
*/
global $slug;
global $content_width;
$content_width = 468; //edit to correct width for your template
/**
 * @desc use any youtube embed param as an att. https://developers.google.com/youtube/player_parameters
 * @param array $atts
 * @return string
 */
function add_video_wrapper($atts){
	extract( shortcode_atts( array(
	'title' => ' ',
	'url' => '',
	'class' => '',
	), $atts ) );
	unset($atts['title']);
	unset($atts['url']);
	unset($atts['class']);
	return '<div class="video '.strtolower($class).'">'.wp_oembed_get($url, $atts).'<h5>'.$title.'</h5></div>';
}
add_shortcode('video','add_video_wrapper');

/**
 * @desc Add additional parameters to oembed returns
 * @param string $html
 * @param string $url
 * @param string $args
 * @return mixed
 */
function videowall_add_params($html,$url,$args){
	foreach($args AS $k=>$v){
		$argstr .= '&'.$k.'='.$v;
	}
	$html = preg_replace('/&feature=oembed/i',$argstr.'&feature=oembed',$html);
	return $html;
}
add_filter('oembed_result','videowall_add_params',10,3);
remove_filter( 'the_content', 'wpautop' );
wp_enqueue_style('videowall-css',get_stylesheet_directory_uri().'/css/videowall.css');

And the LESS:

.page-template-page-videowall-php{
	.hentry {
		margin-bottom: 10px;
		.entry-title {
			margin-bottom: 1em;
			}
		iframe { display: block; }
		.video {
			border: 1px solid #EDEDED;
		    float: left;
		    margin: 0 12px 24px;
		    width: 450px;
		    }
		.video h5 {
			padding: 4px 12px;
			margin: 0;
			}
		.entry-utility {clear: both;}
		}
}