Created
October 30, 2014 16:40
-
-
Save 350d/effc1f1e5eef7c092cac to your computer and use it in GitHub Desktop.
Wordpress: Youtube + Vimeo shortcodes for responsive layout
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
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&autohide=1&vq=hd720&iv_load_policy=3&rel=0&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