コード例 #1
0
 function vimeo_id($url = '')
 {
     if ($url === '') {
         return FALSE;
     }
     if (_isValidURL($url)) {
         sscanf(parse_url($url, PHP_URL_PATH), '/%d', $vimeo_id);
     } else {
         $vimeo_id = $url;
     }
     return _isValidID($vimeo_id, TRUE) ? $vimeo_id : FALSE;
 }
コード例 #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;
 }