mirror of
https://github.com/friendica/friendica
synced 2025-04-27 10:30:10 +00:00
Move tryoembed to Content\OEmbed
- Add bbcode functions documentation - Add Exception handling to OEmbed::getHTML - Fix formatting
This commit is contained in:
parent
1cd8001833
commit
d8a312d286
2 changed files with 67 additions and 48 deletions
|
@ -15,6 +15,7 @@ use dba;
|
|||
use DOMDocument;
|
||||
use DOMXPath;
|
||||
use DOMNode;
|
||||
use Exception;
|
||||
|
||||
require_once 'include/dba.php';
|
||||
require_once 'mod/proxy.php';
|
||||
|
@ -305,6 +306,27 @@ class OEmbed
|
|||
return allowed_domain($domain, $allowed, true);
|
||||
}
|
||||
|
||||
public static function getHTML($url, $title = null)
|
||||
{
|
||||
// Always embed the SSL version
|
||||
$url = str_replace(array("http://www.youtube.com/", "http://player.vimeo.com/"),
|
||||
array("https://www.youtube.com/", "https://player.vimeo.com/"), $url);
|
||||
|
||||
$o = OEmbed::fetchURL($url);
|
||||
|
||||
if (!is_object($o) || $o->type == 'error') {
|
||||
throw new Exception('OEmbed failed for URL: ' . $url);
|
||||
}
|
||||
|
||||
if (x($title)) {
|
||||
$o->title = $title;
|
||||
}
|
||||
|
||||
$html = OEmbed::formatObject($o);
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Generates the iframe HTML for an oembed attachment.
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue