/** * Embed a YouTube video * * Write out XHTML to embed a YouTube video * * @since 2.0 * * @uses vye_get_parameters Extract parameters from input * @uses vye_get_embed_type Work out the correct embed type to use * @uses vye_set_autohide Set correct autohide parameter * @uses vye_generate_youtube_code Generate the YouTube code * * @param string $content YouTube video ID * @param string $paras List of parameters * @param string $style Optional CSS */ function youtube_video_embed($content, $paras = '', $style = '') { $width = vye_get_parameters($paras, 'width'); $height = vye_get_parameters($paras, 'height'); $fullscreen = vye_get_parameters($paras, 'fullscreen'); $related = vye_get_parameters($paras, 'related'); $autoplay = vye_get_parameters($paras, 'autoplay'); $loop = vye_get_parameters($paras, 'loop'); $start = vye_get_parameters($paras, 'start'); $info = vye_get_parameters($paras, 'info'); $annotation = vye_get_parameters($paras, 'annotation'); $cc = vye_get_parameters($paras, 'cc'); $link = vye_get_parameters($paras, 'link'); $react = vye_get_parameters($paras, 'react'); $stop = vye_get_parameters($paras, 'stop'); $sweetspot = vye_get_parameters($paras, 'sweetspot'); $embedplus = vye_get_parameters($paras, 'embedplus'); $disablekb = vye_get_parameters($paras, 'disablekb'); $ratio = vye_get_parameters($paras, 'ratio'); $autohide = vye_get_parameters($paras, 'autohide'); $controls = vye_get_parameters($paras, 'controls'); $type = vye_get_parameters($paras, 'type'); $profile = vye_get_parameters($paras, 'profile'); $list = vye_get_parameters($paras, 'list'); $audio = vye_get_parameters($paras, 'audio'); $template = vye_get_parameters($paras, 'template'); $hd = vye_get_parameters($paras, 'hd'); $color = vye_get_parameters($paras, 'color'); $theme = vye_get_parameters($paras, 'theme'); $https = vye_get_parameters($paras, 'ssl'); $dynamic = vye_get_parameters($paras, 'dynamic'); $search = vye_get_parameters($paras, 'search'); $user = vye_get_parameters($paras, 'user'); $vq = vye_get_parameters($paras, 'vq'); // Get Embed type $type = vye_get_embed_type($type, $embedplus); // Set up Autohide parameter $autohide = vye_set_autohide($autohide); echo vye_generate_youtube_code($content, $type, $width, $height, vye_convert($fullscreen), vye_convert($related), vye_convert($autoplay), vye_convert($loop), $start, vye_convert($info), vye_convert_3($annotation), vye_convert($cc), $style, vye_convert($link), vye_convert($react), $stop, vye_convert($sweetspot), vye_convert($disablekb), $ratio, $autohide, $controls, $profile, $list, vye_convert($audio), $template, vye_convert($hd), $color, $theme, vye_convert($https), vye_convert($dynamic), vye_convert($search), vye_convert($user), $vq); return; }
/** * Video shortcode * * Use shortcode parameters to embed a YouTube video or playlist * * @since 2.0 * * @uses vye_get_embed_type Get the embed type * @uses vye_set_autohide Get the autohide parameter * @uses vye_set_general_defaults Set default options * @uses vye_generate_youtube_code Generate the embed code * * @param string $paras Shortcode parameters * @param string $content Shortcode content * @param string $alt_shortcode The number of the alternative shortcode used * @return string YouTube embed code */ function vye_video_shortcode($paras = '', $content = '', $callback = '', $alt_shortcode = false) { extract(shortcode_atts(array('width' => '', 'height' => '', 'fullscreen' => '', 'related' => '', 'autoplay' => '', 'loop' => '', 'start' => '', 'info' => '', 'annotation' => '', 'cc' => '', 'style' => '', 'stop' => '', 'disablekb' => '', 'ratio' => '', 'autohide' => '', 'controls' => '', 'profile' => '', 'id' => '', 'url' => '', 'rel' => '', 'fs' => '', 'cc_load_policy' => '', 'iv_load_policy' => '', 'showinfo' => '', 'youtubeurl' => '', 'template' => '', 'list' => '', 'color' => '', 'theme' => '', 'ssl' => '', 'height' => '', 'width' => '', 'dynamic' => '', 'h' => '', 'w' => '', 'search' => '', 'user' => '', 'modest' => '', 'playsinline' => '', 'html5' => ''), $paras)); // If no profile specified and an alternative shortcode used, get that shortcodes default profile if ($profile == '' && $alt_shortcode) { // Get general options $options = vye_set_general_defaults(); $profile = $options['alt_profile']; } // If an alternative field is set, use it if ($id != '' && $content == '') { $content = $id; } if ($url != '' && $content == '') { $content = $url; } if ($youtubeurl != '' && $content == '') { $content = $youtubeurl; } if ($h != '' && $height == '') { $height = $h; } if ($w != '' && $width == '') { $width = $w; } if ($rel != '' && $related == '') { $related = $rel; } if ($fs != '' && $fullscreen == '') { $fullscreen = $fs; } if ($cc_load_policy != '' && $cc == '') { $cc = $cc_load_policy; } if ($iv_load_policy != '' && $annotation == '') { $annotation = $iv_load_policy; } if ($showinfo != '' && $info == '') { $info = $showinfo; } // If ID was not passed in the content and the first parameter is set, assume that to be the ID if ($content == '' && $paras[0] != '') { $content = $paras[0]; if (substr($content, 0, 1) == ":" or substr($content, 0, 1) == "=") { $content = substr($content, 1); } if (array_key_exists(1, $paras)) { if ($paras[1] != '') { $width = $paras[1]; } } if (array_key_exists(2, $paras)) { if ($paras[2] != '') { $height = $paras[2]; } } } // Set up Autohide parameter $autohide = vye_set_autohide($autohide); // Create YouTube code $youtube_code = vye_generate_youtube_code($content, $width, $height, vye_convert($fullscreen), vye_convert($related), vye_convert($autoplay), vye_convert($loop), $start, vye_convert($info), vye_convert_3($annotation), vye_convert($cc), $style, $stop, vye_convert($disablekb), $ratio, $autohide, $controls, $profile, $list, $template, $color, $theme, vye_convert($ssl), vye_convert($dynamic), vye_convert($search), vye_convert($user), vye_convert($modest), vye_convert($playsinline), vye_convert($html5)); return apply_filters('a3_lazy_load_html', do_shortcode($youtube_code)); }