public function getUrlInfo($body = null)
{
$results = array();
if ($providers = $this->getProviders($body)) {
foreach ($providers as $url => $service) {
$results[$url] = $service->getInfo();
$this->errors = array_merge($this->errors, $service->getErrors());
}
}
return array_filter($results);
}
/** * Replace embeddable URLs with the embed code. * * @param string $text * * @return string */ public static function OEmbed($text) { $embera = new Embera(); if ($data = $embera->getUrlInfo($text)) { $table = []; foreach ($data as $url => $service) { if (!empty($service['html'])) { $table[$url] = $service['html']; } } foreach ($table as $url => $replacement) { $text = preg_replace('~(?<![\'\\"])' . preg_quote($url) . '(?![\'\\"])(?!\\</a\\>)~', $replacement, $text); } } return $text; }