3 * @copyright Copyright (C) 2010-2021, the Friendica project
5 * @license GNU AGPL version 3 or any later version
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Affero General Public License as
9 * published by the Free Software Foundation, either version 3 of the
10 * License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Affero General Public License for more details.
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
22 namespace Friendica\Module;
24 use Friendica\BaseModule;
25 use Friendica\Content;
27 use Friendica\Util\Strings;
32 * Displays stored embed content based on a base64 hash of a remote URL
34 * Example: /oembed/aHR0cHM6Ly9...
36 * @author Hypolite Petovan <hypolite@mrpetovan.com>
38 class Oembed extends BaseModule
40 public static function content(array $parameters = [])
44 // Unused form: /oembed/b2h?url=...
45 if ($a->argv[1] == 'b2h') {
46 $url = ["", trim(hex2bin($_REQUEST['url']))];
47 echo Content\OEmbed::replaceCallback($url);
51 // Unused form: /oembed/h2b?text=...
52 if ($a->argv[1] == 'h2b') {
53 $text = trim(hex2bin($_REQUEST['text']));
54 echo Content\OEmbed::HTML2BBCode($text);
58 // @TODO: Replace with parameter from router
61 $url = Strings::base64UrlDecode($a->argv[1]);
62 $j = Content\OEmbed::fetchURL($url);
64 // workaround for media.ccc.de (and any other endpoint that return size 0)
65 if (substr($j->html, 0, 7) == "<iframe" && strstr($j->html, 'width="0"')) {
66 $j->html = '<style>html,body{margin:0;padding:0;} iframe{width:100%;height:100%;}</style>' . $j->html;
67 $j->html = str_replace('width="0"', '', $j->html);
68 $j->html = str_replace('height="0"', '', $j->html);
71 echo '</body></html>';