123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613 |
- <?php
- /**
- * @file
- * This file contains all codecs provided by Video Filter.
- */
- /**
- * Implements hook_codec_info().
- */
- function video_filter_codec_info() {
- $codecs = array();
- $codecs['archive'] = array(
- 'name' => t('Archive.org'),
- 'sample_url' => 'http://www.archive.org/details/DrupalconBoston2008-TheStateOfDrupal',
- 'callback' => 'video_filter_archive',
- 'html5_callback' => 'video_filter_archive',
- 'regexp' => '/archive\.org\/details\/([\w-_]+)/i',
- 'ratio' => 4 / 3,
- );
- $codecs['bliptv'] = array(
- 'name' => t('Blip.tv'),
- 'sample_url' => 'http://blip.tv/file/123456',
- 'callback' => 'video_filter_bliptv',
- 'regexp' => array(
- '@blip\.tv/rss/flash/([^"\&\?/]+)@i',
- '@blip\.tv/file/view/([^"\&\?/]+)@i',
- '@blip\.tv/file/([^"\&\?/]+)@i',
- '@blip\.tv/play/([^"\&\?/]+)@i',
- ),
- 'ratio' => 16 / 9,
- 'control_bar_height' => 30,
- );
- $codecs['capped'] = array(
- 'name' => t('Capped'),
- 'sample_url' => 'http://capped.tv/playeralt.php?vid=some-title',
- 'callback' => 'video_filter_capped',
- 'regexp' => '/capped\.tv\/([a-zA-Z0-9\-_]+)/',
- 'ratio' => 425 / 355,
- );
- $codecs['collegehumor'] = array(
- 'name' => t('College Humor'),
- 'sample_url' => 'http://www.collegehumor.com/video:1234567890',
- 'callback' => 'video_filter_collegehumor',
- 'regexp' => '/collegehumor\.com\/video\:([0-9]+)/',
- 'ratio' => 16 / 9,
- 'control_bar_height' => 0,
- );
- $codecs['dailymotion'] = array(
- 'name' => t('DailyMotion'),
- 'sample_url' => 'http://www.dailymotion.com/video/some_video_title',
- 'callback' => 'video_filter_dailymotion',
- 'regexp' => '/dailymotion\.com\/video\/([a-z0-9\-_]+)/i',
- 'ratio' => 4 / 3,
- 'control_bar_height' => 20,
- );
- $codecs['flickr_slideshows'] = array(
- 'name' => t('Flickr Slideshows'),
- 'sample_url' => 'http://www.flickr.com/photos/username/sets/1234567890/show/',
- 'callback' => 'video_filter_flickr_slideshows',
- 'regexp' => '/flickr\.com\/photos\/([a-zA-Z0-9@_\-]+)\/sets\/([0-9]+)\/?[show]?\/?/i',
- 'ratio' => 4 / 3,
- 'control_bar_height' => 0,
- );
- $codecs['flickr_video'] = array(
- 'name' => t('Flickr Video'),
- 'sample_url' => 'http://www.flickr.com/photos/hansnilsson/1234567890/',
- 'callback' => 'video_filter_flickr_video',
- 'regexp' => '/flickr\.com\/photos\/([a-zA-Z0-9@_\-]+)\/([0-9]+)/',
- 'ratio' => 4 / 3,
- 'control_bar_height' => 0,
- );
- $codecs['gametrailers'] = array(
- 'name' => t('Game Trailers'),
- 'sample_url' => 'http://www.gametrailers.com/video/some-title/12345',
- 'callback' => 'video_filter_gametrailers',
- 'regexp' => array(
- '/gametrailers\.com\/player\/([0-9]+)/',
- '/gametrailers\.com\/video\/([a-z0-9\-_]+)\/([0-9]+)/',
- ),
- 'ratio' => 16 / 9,
- );
- $codecs['gamevideos'] = array(
- 'name' => t('Game Videos'),
- 'sample_url' => 'http://gamevideos.1up.com/video/id/12345',
- 'callback' => 'video_filter_gamevideos',
- 'regexp' => '/gamevideos\.1up\.com\/video\/id\/([0-9]+)/',
- 'ratio' => 500 / 319,
- );
- $codecs['godtube'] = array(
- 'name' => t('GodTube'),
- 'sample_url' => 'http://www.godtube.com/watch/?v=123abc',
- 'callback' => 'video_filter_godtube',
- 'regexp' => '/godtube\.com\/watch\/\?v=([a-z0-9\-_]+)/i',
- 'ratio' => 400 / 283,
- 'control_bar_height' => 40,
- );
- $codecs['google'] = array(
- 'name' => t('Google Video'),
- 'sample_url' => 'http://video.google.com/videoplay?docid=-uN1qUeId',
- 'callback' => 'video_filter_google',
- 'regexp' => '/video\.google\.[a-z]+\.?[a-z]+?\/videoplay\?docid=(\-?[0-9]+)/',
- 'ratio' => 400 / 326,
- );
- $codecs['metacafe'] = array(
- 'name' => t('Meta Cafe'),
- 'sample_url' => 'http://www.metacafe.com/watch/1234567890/some_title/',
- 'callback' => 'video_filter_metacafe',
- 'regexp' => '/metacafe\.com\/watch\/([a-z0-9\-_]+)\/([a-z0-9\-_]+)/i',
- 'ratio' => 400 / 313,
- 'control_bar_height' => 32,
- );
- $codecs['myspace'] = array(
- 'name' => t('MySpace'),
- 'sample_url' => 'http://myspace.com/video/vid/1234567890',
- 'callback' => 'video_filter_myspace',
- 'regexp' => array(
- '/vids\.myspace\.com\/.*VideoID=([0-9]+)/i',
- '/myspace\.com\/video\/([a-z])+\/([0-9]+)/i',
- '/myspace\.com\/video\/([a-z0-9\-_]+)\/([a-z0-9\-_]+)\/([a-z0-9]+)/i',
- '/myspace\.com\/([a-z0-9\-_]+)\/videos\/([a-z0-9\-_]+)\/([a-z0-9]+)/i',
- ),
- 'ratio' => 620 / 400,
- 'control_bar_height' => 40,
- );
- $codecs['picasa_slideshows'] = array(
- 'name' => t('Picasa Slideshows'),
- 'sample_url' => 'http://picasaweb.google.com/data/feed/base/user/USER_NAME/albumid/5568104935784209834?alt=rss&kind=photo&hl=en_US',
- 'callback' => 'video_filter_picasa_slideshows',
- 'instructions' => t('You must use the URL of the RSS feed for the Picasa album:') .
- '<ol>' .
- '<li>' . t('View the album in Picasa (you should see thumbnails, not a slideshow).') . '</li>' .
- '<li>' . t('Find the "RSS" link and click it.') . '</li>' .
- '<li>' . t('Copy the resulting URL from the browser address bar. Example:') . '<br />' .
- '<code>[video: http://picasaweb.google.com/data/feed/base/user/USER_NAME/albumid/5568104935784209834?alt=rss&kind=photo&hl=en_US]</code>' .
- '</li>' .
- '</ol>',
- 'regexp' => '/picasaweb\.google\.com\/data\/feed\/base\/user\/([a-zA-Z0-9@_\-\.]+)\/albumid\/([a-z0-9]+)/i',
- 'ratio' => 800 / 600,
- );
- $codecs['slideshare'] = array(
- 'name' => t('Slideshare'),
- 'sample_url' => 'http://slideshare.net/1759622',
- 'callback' => 'video_filter_slideshare',
- 'instructions' => t('You need to construct your own URL, using the "Wordpress Embed" code from Slideshare, extract the "id", and form the URL like this: slideshare.net/1759622'),
- 'regexp' => array(
- '/slideshare\.net\/\?id=([a-z0-9]+)/',
- '/slideshare\.net\/([a-z0-9]+)/',
- ),
- 'ratio' => 425 / 355,
- );
- $codecs['streamhoster'] = array(
- 'name' => t('Streamhoster'),
- 'sample_url' => 'http://web26.streamhoster.com/username/filename.flv',
- 'callback' => 'video_filter_streamhoster',
- 'regexp' => '/([a-z0-9]+)\:\/\/([a-z0-9\-_]+)\.streamhoster\.com\/([a-z0-9\-_]+)\/([a-z0-9\-_\.]+)/i',
- 'ratio' => 480 / 360,
- );
- $codecs['teachertube'] = array(
- 'name' => t('Teachertube'),
- 'sample_url' => 'http://www.teachertube.com/viewVideo.php?video_id=VIDEOID',
- 'callback' => 'video_filter_teachertube',
- 'regexp' => '/teachertube\.com\/viewVideo.php\?video_id\=([0-9]+)/i',
- 'ratio' => 16 / 9,
- );
- $codecs['vimeo'] = array(
- 'name' => t('Vimeo'),
- 'sample_url' => 'http://www.vimeo.com/123456',
- 'callback' => 'video_filter_vimeo',
- 'html5_callback' => 'video_filter_vimeo_html5',
- 'regexp' => '/vimeo\.com\/([0-9]+)/',
- 'ratio' => 16 / 9,
- 'control_bar_height' => 0,
- );
- $codecs['wistia'] = array(
- 'name' => t('Wistia'),
- 'sample_url' => 'http://wistia.com/medias/9pj9n6ftlk',
- 'callback' => 'video_filter_wistia_html5',
- 'html5_callback' => 'video_filter_wistia_html5',
- 'regexp' => '@https?://(.+\.)?(wistia\.com|wi\.st)/((m|medias|projects)|embed/(iframe|playlists))/([a-zA-Z0-9]+)@',
- );
- $codecs['youtube'] = array(
- 'name' => t('YouTube'),
- 'sample_url' => 'http://www.youtube.com/watch?v=uN1qUeId',
- 'callback' => 'video_filter_youtube',
- 'html5_callback' => 'video_filter_youtube_html5',
- 'regexp' => array(
- '/youtube\.com\/watch\?v=([a-z0-9\-_]+)/i',
- '/youtu.be\/([a-z0-9\-_]+)/i',
- '/youtube\.com\/v\/([a-z0-9\-_]+)/i',
- ),
- 'ratio' => 16 / 9,
- 'control_bar_height' => 25,
- );
- $codecs['youtube_playlist'] = array(
- 'name' => t('YouTube (Playlist)'),
- 'sample_url' => 'http://www.youtube.com/playlist?list=uN1qUeId',
- 'callback' => 'video_filter_youtube_playlist_html5',
- 'regexp' => array(
- '/youtube\.com\/playlist\?list=([a-z0-9\-_]+)/i',
- ),
- 'ratio' => 16 / 9,
- 'control_bar_height' => 25,
- );
- return $codecs;
- }
- /**
- * Callback for Archive.org codec.
- *
- * @see video_filter_codec_info()
- */
- function video_filter_archive($video) {
- $video['source'] = 'http://www.archive.org/embed/' . $video['codec']['matches'][1];
- return video_filter_iframe($video);
- }
- /**
- * Callback for Blip.tv codec.
- *
- * @see video_filter_codec_info()
- */
- function video_filter_bliptv($video) {
- $id = $video['codec']['matches'][1];
- // Since video ID in URL is different than in embed code, use API to lookup
- // the embed code video ID. Adapted from emfield.module.
- $result = drupal_http_request('http://blip.tv/file/' . $id . '?skin=api');
- if ($result->code == 200) {
- $parser = drupal_xml_parser_create($result->data);
- $vals = array();
- $index = array();
- xml_parse_into_struct($parser, $result->data, $vals, $index);
- xml_parser_free($parser);
- $response = array();
- // @todo: What's $arghash supposed to be? It's undefined.
- $response['_emfield_arghash'] = $arghash;
- $level = array();
- $start_level = 1;
- foreach ($vals as $xml_elem) {
- if ($xml_elem['type'] == 'open') {
- if (array_key_exists('attributes', $xml_elem)) {
- list($level[$xml_elem['level']], $extra) = array_values($xml_elem['attributes']);
- }
- else {
- $level[$xml_elem['level']] = $xml_elem['tag'];
- }
- }
- if ($xml_elem['type'] == 'complete') {
- $php_stmt = '$response';
- while ($start_level < $xml_elem['level']) {
- $php_stmt .= '[$level[' . $start_level . ']]';
- $start_level++;
- }
- $php_stmt .= '[$xml_elem[\'tag\']][] = $xml_elem[\'value\'];' . $php_stmt . '[$xml_elem[\'tag\']][] = $xml_elem[\'attributes\'];';
- eval($php_stmt);
- $start_level--;
- }
- }
- $id = $response['EMBEDLOOKUP'][0];
- // Protect from XSS.
- if (preg_match("/[^A-Za-z0-9]/", $id, $matches)) {
- watchdog('Video Filter', 'A faulty Blip.tv ID has been detected.');
- $id = 0;
- }
- }
- $video['source'] = 'http://blip.tv/play/' . $id;
- $params = array(
- 'allowscriptaccess' => 'always',
- );
- return video_filter_flash($video, $params);
- }
- /**
- * Callback for Capped codec.
- *
- * @see video_filter_codec_info()
- */
- function video_filter_capped($video) {
- $video['source'] = 'http://capped.micksam7.com/playeralt.swf?vid=' . $video['codec']['matches'][1];
- return video_filter_flash($video);
- }
- /**
- * Callback for College Humor codec.
- *
- * @see video_filter_codec_info()
- */
- function video_filter_collegehumor($video) {
- $video['source'] = 'http://www.collegehumor.com/moogaloop/moogaloop.swf?clip_id=' . $video['codec']['matches'][1] . '&fullscreen=1';
- return video_filter_flash($video);
- }
- /**
- * Callback for DailyMotion codec.
- *
- * @see video_filter_codec_info()
- */
- function video_filter_dailymotion($video) {
- $video['source'] = 'http://www.dailymotion.com/swf/' . $video['codec']['matches'][1];
- return video_filter_flash($video);
- }
- /**
- * Callback for Flickr Slideshows codec.
- *
- * @see video_filter_codec_info()
- */
- function video_filter_flickr_slideshows($video) {
- $slideshow_player_url = 'http://www.flickr.com/apps/slideshow/show.swf?v=67348';
- $video['source'] = $slideshow_player_url . ($video['autoplay'] ? '&autoplay=1' : '');
- $user_name = $video['codec']['matches'][1];
- $set_id = $video['codec']['matches'][2];
- $params['flashvars'] = "&offsite=true&lang=en-us&page_show_url=%2Fphotos%2F$user_name%2Fsets%2F$set_id%2Fshow%2F&page_show_back_url=%2Fphotos%2F$user_name%2Fsets%2F$set_id%2F&set_id=$set_id&jump_to=";
- return video_filter_flash($video, $params);
- }
- /**
- * Callback for Flickr Video codec.
- *
- * @see video_filter_codec_info()
- */
- function video_filter_flickr_video($video) {
- $video['source'] = 'http://www.flickr.com/apps/video/stewart.swf?v=1.161';
- $params['flashvars'] = '&photo_id=' . $video['codec']['matches'][2] . '&flickr_show_info_box=true';
- return video_filter_flash($video, $params);
- }
- /**
- * Callback for Game Trailers codec.
- *
- * @see video_filter_codec_info()
- */
- function video_filter_gametrailers($video) {
- if (is_numeric($video['codec']['matches'][1])) {
- $match = $video['codec']['matches'][1];
- }
- elseif (is_numeric($video['codec']['matches'][2])) {
- $match = $video['codec']['matches'][2];
- }
- $video['source'] = 'http://media.mtvnservices.com/embed/mgid:moses:video:gametrailers.com:' . $match;
- return video_filter_iframe($video);
- }
- /**
- * Callback for Game Videos codec.
- *
- * @see video_filter_codec_info()
- */
- function video_filter_gamevideos($video) {
- $video['source'] = 'http://gamevideos.1up.com/swf/gamevideos12.swf?embedded=1&fullscreen=1&autoplay=0&src=http://gamevideos.1up.com/do/videoListXML%3Fid%3D' . $video['codec']['matches'][1];
- return video_filter_flash($video);
- }
- /**
- * Callback for GodTube codec.
- *
- * @see video_filter_codec_info()
- */
- function video_filter_godtube($video) {
- $video['source'] = 'http://www.godtube.com/embed/watch/' . $video['codec']['matches'][1];
- return video_filter_iframe($video);
- }
- /**
- * Callback for Google Video codec.
- *
- * @see video_filter_codec_info()
- */
- function video_filter_google($video) {
- $video['source'] = 'http://video.google.com/googleplayer.swf?docId=' . $video['codec']['matches'][1];
- return video_filter_flash($video);
- }
- /**
- * Callback for Meta Cafe codec.
- *
- * @see video_filter_codec_info()
- */
- function video_filter_metacafe($video) {
- $video['source'] = 'http://metacafe.com/fplayer/' . $video['codec']['matches'][1] . '/' . $video['codec']['matches'][2] . '.swf';
- return video_filter_flash($video);
- }
- /**
- * Callback for MySpace codec.
- *
- * @see video_filter_codec_info()
- */
- function video_filter_myspace($video) {
- // The last match is the ID we need.
- $last = count($video['codec']['matches']);
- $video['source'] = 'http://mediaservices.myspace.com/services/media/embed.aspx/m=' . $video['codec']['matches'][$last - 1];
- return video_filter_flash($video, $params);
- }
- /**
- * Callback for Picasa Slideshows codec.
- *
- * @see video_filter_codec_info()
- */
- function video_filter_picasa_slideshows($video) {
- $video['source'] = 'http://picasaweb.google.com/s/c/bin/slideshow.swf';
- $user_name = $video['codec']['matches'][1];
- $set_id = $video['codec']['matches'][2];
- $params['flashvars'] = "host=picasaweb.google.com&&feat=flashalbum&RGB=0x000000&feed=http%3A%2F%2Fpicasaweb.google.com%2Fdata%2Ffeed%2Fapi%2Fuser%2F" . $user_name . "%2Falbumid%2F" . $set_id . "%3Falt%3Drss%26kind%3Dphoto%26" . ($video['autoplay'] ? '' : '&noautoplay=1');
- return video_filter_flash($video, $params);
- }
- /**
- * Callback for Slideshare codec.
- *
- * @see video_filter_codec_info()
- */
- function video_filter_slideshare($video) {
- $video['source'] = 'http://www.slideshare.net/slideshow/embed_code/' . $video['codec']['matches'][1];
- return video_filter_iframe($video);
- }
- /**
- * Callback for Streamhoster codec.
- *
- * @see video_filter_codec_info()
- */
- function video_filter_streamhoster($video) {
- $video['source'] = 'http://public.streamhoster.com/Resources/Flash/JWFLVMediaPlayer/mediaplayer.swf';
- $params = array('allowscriptaccess' => 'always');
- $protocol = $video['codec']['matches'][1];
- if ($protocol == 'rtmp') {
- $params['flashvars'] = 'file=' . urlencode('/' . $video['codec']['matches'][4]);
- $params['flashvars'] .= '&streamer=' . urlencode('rtmp://' . $video['codec']['matches'][2] . '.streamhoster.com/' . $video['codec']['matches'][3]);
- $params['flashvars'] .= '&type=rtmp';
- }
- elseif ($protocol == 'http') {
- $params['flashvars'] = 'file=' . urlencode('http://' . $video['codec']['matches'][2] . '.streamhoster.com/' . $video['codec']['matches'][3] . '/' . $video['codec']['matches'][4]);
- $params['flashvars'] .= '&type=video';
- }
- $params['flashvars'] .= '&width=' . $video['width'];
- $params['flashvars'] .= '&height=' . $video['height'];
- $params['flashvars'] .= !empty($video['autoplay']) ? '&autostart=true' : '&autostart=false';
- return video_filter_flash($video, $params);
- }
- /**
- * Callback for Teachertube codec.
- *
- * @see video_filter_codec_info()
- */
- function video_filter_teachertube($video) {
- $video['source'] = 'http://www.teachertube.com/embed/player.swf';
- $params['flashvars'] = 'file=http://www.teachertube.com/embedFLV.php?pg=video_' . $video['codec']['matches'][1] . '&menu=false&frontcolor=ffffff&lightcolor=FF0000&logo=http://www.teachertube.com/www3/images/greylogo.swf&skin=http://www.teachertube.com/embed/overlay.swf&volume=80&controlbar=over&displayclick=link&viral.link=http://www.teachertube.com/viewVideo.php?video_id=' . $video['codec']['matches'][1] . '&stretching=exactfit&plugins=viral-2&viral.callout=none&viral.onpause=false';
- return video_filter_flash($video, $params);
- }
- /**
- * Callback for Vimeo codec.
- *
- * @see video_filter_codec_info()
- */
- function video_filter_vimeo($video) {
- $video['source'] = 'http://www.vimeo.com/moogaloop.swf?clip_id=' . $video['codec']['matches'][1] . '&server=www.vimeo.com&fullscreen=1&show_title=1&show_byline=1&show_portrait=0&color=&autoplay=' . $video['autoplay'];
- return video_filter_flash($video);
- }
- /**
- * HTML5 callback for Vimeo codec.
- *
- * @see video_filter_codec_info()
- */
- function video_filter_vimeo_html5($video) {
- $video['source'] = 'http://player.vimeo.com/video/' . $video['codec']['matches'][1] . ($video['autoplay'] ? '?autoplay=1' : '');
- return video_filter_iframe($video);
- }
- /**
- * Callback for YouTube codec.
- *
- * @see video_filter_codec_info()
- */
- function video_filter_youtube($video) {
- $attributes = array(
- 'rel' => $video['related'] ? 'rel=1' : 'rel=0',
- 'autoplay' => $video['autoplay'] ? 'autoplay=1' : 'autoplay=0',
- 'fs' => 'fs=1',
- );
- $video['source'] = 'http://www.youtube.com/v/' . $video['codec']['matches'][1] . '?' . implode('&', $attributes);
- $params['wmode'] = 'opaque';
- return video_filter_flash($video, $params);
- }
- /**
- * HTML5 callback for YouTube codec.
- *
- * @see video_filter_codec_info()
- */
- function video_filter_youtube_html5($video) {
- $attributes = array(
- 'rel' => $video['related'] ? 'rel=1' : 'rel=0',
- 'autoplay' => $video['autoplay'] ? 'autoplay=1' : 'autoplay=0',
- 'wmode' => 'wmode=opaque',
- );
- $video['source'] = 'http://www.youtube.com/embed/' . $video['codec']['matches'][1] . '?' . implode('&', $attributes);
- return video_filter_iframe($video);
- }
- /**
- * HTML5 callback for YouTube (Playlist) codec.
- *
- * @see video_filter_codec_info()
- */
- function video_filter_youtube_playlist_html5($video) {
- $attributes = array(
- 'rel' => $video['related'] ? 'rel=1' : 'rel=0',
- 'autoplay' => $video['autoplay'] ? 'autoplay=1' : 'autoplay=0',
- 'wmode' => 'wmode=opaque',
- );
- $video['source'] = 'http://www.youtube.com/embed/videoseries?list=' . $video['codec']['matches'][1] . '&' . implode('&', $attributes);
- return video_filter_iframe($video);
- }
- /**
- * Callback for Wistia codec.
- *
- * Adapted from the media_wistia module.
- *
- * @see video_filter_codec_info()
- */
- function video_filter_wistia_html5($video) {
- $video_code = $video['codec']['matches'][6];
- $matches = $video['codec']['matches'];
- $embed_type = ($matches[3] == 'projects' || $matches[5] == 'playlists') ? 'playlists' : 'iframe';
- // Get embed code via oEmbed.
- $endpoint = 'http://fast.wistia.com/oembed';
- $options = array(
- 'url' => "http://fast.wistia.com/embed/{$embed_type}/{$video_code}",
- 'width' => $video['width'],
- 'height' => $video['height'],
- );
- $data = video_filter_oembed_request($endpoint, $options);
- $html = $data['html'];
- // See if the video source is already an iframe src.
- $pattern = '@https?://fast.wistia.com/embed/(iframe|playlists)/[a-zA-Z0-9]+\?+.+@';
- $matches = array();
- if (preg_match($pattern, $video['source'], $matches)) {
- // Replace the oEmbed iframe src with that provided in the token, in order
- // to support embed builder URLs.
- $pattern = '@https?://fast.wistia.com/embed/(iframe|playlists)/[a-zA-Z0-9]+\?[^"]+@';
- $replacement = $matches[0];
- $html = preg_replace($pattern, $replacement, $html);
- }
- return $html;
- }
|