Embeding A YouTube Video

Hi! I'm having trouble embedding a youtube video into items. As a new user I'm at a loss. I was able to embed a video into Simple Pages but it will not transfer over into my exhibit. Please help!

You would need to edit your item and/or exhibit templates for this to work but I have used this method in the past.

Upload the original video (or a screenshot or some other file if you prefer), then add the URL of the video to the Relation field of the file. The script will check for Vimeo or YouTube links and create the embed code dynamically.

Add a custom function to your custom.php file...

** Checks file metadata record for embeddable version of a video file
** Because YouTube and Vimeo have better compression, etc.
** returns string $html | false
function embeddableVersion($file,$field=array('Dublin Core','Relation')){

	$youtube= (strpos(metadata($file,$field), 'youtube.com')) ? metadata($file,$field) : false;
	$vimeo= (strpos(metadata($file,$field), 'vimeo.com')) ? metadata($file,$field) : false;

	if($youtube) {
		// assumes YouTube links look like https://www.youtube.com/watch?v=NW03FB274jg where the v query contains the video identifier
		$html= '<div class="item-file-container"><div class="embed-container youtube" id="v-streaming" style="position: relative;padding-bottom: 56.25%;height: 0; overflow: hidden;"><iframe style="position: absolute;top: 0;left: 0;width: 100%;height: 100%;" src="//www.youtube.com/embed/'.$id.'" frameborder="0" width="725" height="410" allowfullscreen></iframe></div></div>';

		return $html;
	elseif($vimeo) {
		// assumes the Vimeo links look like http://vimeo.com/78254514 where the path string contains the video identifier
		$html= '<div class="item-file-container"><div class="embed-container vimeo" id="v-streaming" style="padding-top:0; height: 0; padding-top: 25px; padding-bottom: 67.5%; margin-bottom: 10px; position: relative; overflow: hidden;"><iframe style=" top: 0; left: 0; width: 100%; height: 100%; position: absolute;" src="//player.vimeo.com/video'.$id.'?color=333" width="725" height="410" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe></div></div>';

		return $html;
		return false;

In your theme template(s), you'd then add something like this while looping through your item files...

foreach (loop('files', $item->Files) as $file){
     if(embeddableVersion($file) !== false){
          echo embeddableVersion($file);
          // do whatever default behavior

There's probably a cleaner way to do this using a plugin but if this approach is an option for you, it should work well enough.