Last active
March 13, 2019 11:30
-
-
Save millipedia/10017099 to your computer and use it in GitHub Desktop.
CMS Made Simple User Defined Tag for embedding a Youtube video
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
// write out an embed tag for a youtube vid. | |
$ytCode=$params['code']; | |
if(isset($params['height'])){ | |
$height=$params['height']; | |
}else{ | |
$height=290; | |
} | |
if(isset($params['width'])){ | |
$width=$params['width']; | |
}else{ | |
$width=560; | |
} | |
if(isset($params['autoplay'])){ | |
$autoplay=$params['autoplay']; | |
}else{ | |
$autoplay=0; | |
} | |
$vidString='<div class="embed-responsive embed-responsive-16by9">'; | |
$vidString.='<iframe width="'.$width.'" height="'. $height .'" src="https://www.youtube.com/embed/' . $ytCode .'?rel=0&modestbranding=1&showinfo=0" frameborder="0" allowfullscreen></iframe>'; | |
$vidString.='</div>'; | |
echo $vidString; |
There is now a plugin version of this UDT over at https://github.com/millipedia/CMSMS_plugins - you should probably use that instead.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you're using Bootstrap then the tag has the correct classnames for responsive videos or you can use these css classes.