Skip to content

Instantly share code, notes, and snippets.

@350d

350d/finctions.php

Created Oct 30, 2014
Embed
What would you like to do?
Wordpress: Youtube + Vimeo shortcodes for responsive layout
function appthemes_add_quicktags() {
if (wp_script_is('quicktags')){
?>
<script type="text/javascript">
QTags.addButton( 'yt_embed', 'Youtube', '[youtube id="', '"]', 'y', 'Youtube Video', 1 );
QTags.addButton( 'vm_embed', 'Vimeo', '[vimeo id="', '"]', 'v', 'Vimeo Video', 2 );
</script>
<?php
}
}
add_action( 'admin_print_footer_scripts', 'appthemes_add_quicktags' );
function youtube_shortcode($atts) {
extract(shortcode_atts(array('id' => 'KO8EPkgug4c'), $atts));
return '<div class="ytplayer"><iframe src="https://youtube.com/embed/'.$atts['id'].'?controls=1&amp;autohide=1&amp;vq=hd720&amp;iv_load_policy=3&amp;rel=0&amp;showinfo=0" allowfullscreen=""></iframe></div>';
}
function vimeo_shortcode($atts) {
extract(shortcode_atts(array('id' => '12345678'), $atts));
return '<div class="vmplayer"><iframe src="//player.vimeo.com/video/'.$atts['id'].'?title=0&byline=0&portrait=0&hd=0&autoplay=0" allowfullscreen=""></iframe></div>';
}
add_shortcode('youtube', 'youtube_shortcode');
add_shortcode('vimeo', 'vimeo_shortcode');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.