Пример #1
0
/**
 * For bare URLs on their own line of the form
 * http://www.youtube.com/v/9FhMMmqzbD8?fs=1&hl=en_US
 */
function wpcom_youtube_embed_crazy_url($matches, $attr, $url)
{
    return youtube_id($url);
}
Пример #2
0
 function youtube_embed($url_id = '', $width = '', $height = '', $old_embed = FALSE, $hd = FALSE, $https = FALSE, $suggested = FALSE)
 {
     if ($url_id == '') {
         return FALSE;
     }
     if (_isValidID($url_id)) {
         $id = $url_id;
     } else {
         $id = youtube_id($url_id);
     }
     //Contruct the old embed code
     if ($old_embed) {
         if ($hd) {
             $embed = '<object width="1280" height="720">';
         } else {
             $embed = '<object width="' . $width . '" height="' . $height . '">';
         }
         $embed .= '<param name="movie" value="';
         if ($https) {
             $embed .= 'https';
         } else {
             $embed .= 'http';
         }
         $embed .= '://www.youtube-nocookie.com/v/' . $id . '?version=3&amp;hl=en_US&amp;';
         if ($suggested) {
             $embed .= 'rel=0&amp;';
         }
         if ($hd) {
             $embed .= 'hd=1';
         }
         $embed .= '"></param>';
         $embed .= '<param name="allowFullScreen" value="true"></param>';
         $embed .= '<param name="allowscriptaccess" value="always"></param>';
         $embed .= '<embed src="';
         if ($https) {
             $embed .= 'https';
         } else {
             $embed .= 'http';
         }
         $embed .= '://www.youtube-nocookie.com/v/' . $id . '?version=3&amp;hl=en_US';
         if ($hd) {
             $embed .= '&amp;hd=1';
         }
         $embed .= '" type="application/x-shockwave-flash" ';
         if ($hd) {
             $embed .= 'width="1280" height="720" ';
         } else {
             $embed .= 'width="' . $width . '" height="' . $height . '" ';
         }
         $embed .= 'allowscriptaccess="always" allowfullscreen="true"></embed>';
         $embed .= '</object>';
     } else {
         $embed = '<iframe ';
         if ($hd) {
             $embed .= 'width="1280" height="720" ';
         } else {
             $embed .= 'width="' . $width . '" height="' . $height . '" ';
         }
         $embed .= 'src="';
         if ($https) {
             $embed .= 'https';
         } else {
             $embed .= 'http';
         }
         $embed .= '://www.youtube-nocookie.com/embed/' . $id;
         if ($suggested or $hd) {
             $embed .= '?';
         }
         if ($suggested) {
             $embed .= 'rel=0&amp;';
         }
         if ($hd) {
             $embed .= 'hd=1';
         }
         $embed .= '" frameborder="0" allowfullscreen></iframe>';
     }
     return $embed;
 }