function nvweb_template_oembed_url($url) { global $current; // TODO: implement more oembed services $out = $url; // Twitter: https://twitter.com/username/status/status_id if (strpos($url, 'twitter.com/') !== false && strpos($url, '/status') !== false) { $oembed_url = 'https://api.twitter.com/1/statuses/oembed.json?lang=' . $current['lang'] . '&url=' . urlencode($url); // &omit_script=true $response = nvweb_template_oembed_cache('twitter', $oembed_url); if (!empty($response->html)) { $out = $response->html; } } else { if (strpos($url, 'www.youtube.com/watch')) { $oembed_url = 'https://www.youtube.com/oembed?url=' . urlencode($url) . '&format=json'; $response = nvweb_template_oembed_cache('youtube', $oembed_url); if (!empty($response->html)) { $out = $response->html; } } else { if (strpos($url, 'www.vimeo.com/') || strpos($url, 'vimeo.com/')) { $oembed_url = 'https://vimeo.com/api/oembed.json?url=' . urlencode($url); $response = nvweb_template_oembed_cache('vimeo', $oembed_url); if (!empty($response->html)) { $out = $response->html; } } else { if (strpos($url, 'www.instagram.com/p/') || strpos($url, 'instagram.com/p/') || strpos($url, 'instagr.am/p/')) { $oembed_url = 'https://api.instagram.com/oembed?url=' . urlencode($url); $response = nvweb_template_oembed_cache('instagram', $oembed_url); if (!empty($response->html)) { $out = $response->html; } } else { if (strpos($url, 'www.flickr.com/photos/')) { $oembed_url = 'http://www.flickr.com/services/oembed.json?url=' . urlencode($url); $response = nvweb_template_oembed_cache('flickr', $oembed_url); if (!empty($response->html)) { $out = $response->html; } } else { if (strpos($url, 'www.dailymotion.com/video/')) { $oembed_url = 'http://www.dailymotion.com/services/oembed?format=json&url=' . urlencode($url); $response = nvweb_template_oembed_cache('dailymotion', $oembed_url); if (!empty($response->html)) { $out = $response->html; } } else { if (strpos($url, 'www.scribd.com/doc/')) { $oembed_url = 'http://www.scribd.com/services/oembed?format=json&url=' . urlencode($url); $response = nvweb_template_oembed_cache('scribd', $oembed_url); if (!empty($response->html)) { $out = $response->html; } } else { if (strpos($url, 'soundcloud.com/')) { $oembed_url = 'https://soundcloud.com/oembed?format=json&url=' . urlencode($url); $response = nvweb_template_oembed_cache('soundcloud', $oembed_url); if (!empty($response->html)) { $out = $response->html; } } } } } } } } } return $out; }
public function load_from_vimeo($reference, $cache = true) { global $website; if ($cache) { $cache = 30 * 24 * 60; } else { $cache = 0; } $info = nvweb_template_oembed_cache('vimeo', 'http://vimeo.com/api/oembed.json?url=http://vimeo.com/' . $reference . '&format=json', $cache); if (empty($info)) { return false; } $this->id = 'vimeo#' . $reference; $this->type = 'video'; $this->name = $info->title; $this->size = NULL; $this->mime = 'video/vimeo'; $this->width = $info->width; $this->height = $info->height; $this->uploaded_by = $info->author_name; $this->access = 0; $this->permission = 0; $this->enabled = 1; $this->video_thumbnail_retrieve($info->thumbnail_url, "vimeo", $reference); $this->extra = array('reference' => $info->video_id, 'link' => 'https://www.vimeo.com/' . $reference, 'thumbnail_url' => str_replace('http://', 'https://', $info->thumbnail_url), 'thumbnail_big' => str_replace('http://', 'https://', $info->thumbnail_url), 'thumbnail_cache' => 'private/' . $website->id . '/thumbnails/video-vimeo-' . $reference, 'thumbnail_cache_absolute' => file::file_url('private/' . $website->id . '/thumbnails/video-vimeo-' . $reference) . '&type=image', 'duration' => '', 'embed_code' => '<iframe src="https://player.vimeo.com/video/' . $reference . '?" frameborder="0" allowfullscreen></iframe>'); }