Video embed not working

I have a set of “if” statements that look for either a Youtube or Vimeo code but it is showing both in the page content. I only want it to show the video that is referenced.

Here is the template code and the YAML reference.


Youtube: p-RFuw4nGT4

 <?php if($page->youtube()): ?>
  <?php $video = $page->youtube() ?>
  <iframe width="720" height="405" src="http://www.youtube.com/embed/<?php echo ($video) ?>" frameborder="0" allowfullscreen></iframe>
  <?php endif ?>

  <?php if($page->vimeo()): ?>
  <?php $video = $page->vimeo() ?>
  <iframe src="http://player.vimeo.com/video/<?php echo($video) ?>?badge=0" width="720" height="405" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>
  <?php endif ?>

You want to check if the field is filled or not

if($page->youtube()->isNotEmpty()): ?>

Thank you so much, worked perfect