3 namespace Friendica\Module;
5 use Friendica\BaseModule;
8 use Friendica\Util\Strings;
13 * Displays stored embed content based on a base64 hash of a remote URL
15 * Example: /oembed/aHR0cHM6Ly9...
17 * @author Hypolite Petovan <hypolite@mrpetovan.com>
19 class Oembed extends BaseModule
21 public static function content(array $parameters = [])
25 // Unused form: /oembed/b2h?url=...
26 if ($a->argv[1] == 'b2h') {
27 $url = ["", trim(hex2bin($_REQUEST['url']))];
28 echo Content\OEmbed::replaceCallback($url);
32 // Unused form: /oembed/h2b?text=...
33 if ($a->argv[1] == 'h2b') {
34 $text = trim(hex2bin($_REQUEST['text']));
35 echo Content\OEmbed::HTML2BBCode($text);
39 // @TODO: Replace with parameter from router
42 $url = Strings::base64UrlDecode($a->argv[1]);
43 $j = Content\OEmbed::fetchURL($url);
45 // workaround for media.ccc.de (and any other endpoint that return size 0)
46 if (substr($j->html, 0, 7) == "<iframe" && strstr($j->html, 'width="0"')) {
47 $j->html = '<style>html,body{margin:0;padding:0;} iframe{width:100%;height:100%;}</style>' . $j->html;
48 $j->html = str_replace('width="0"', '', $j->html);
49 $j->html = str_replace('height="0"', '', $j->html);
52 echo '</body></html>';