diff options
author | Mario Vavti <mario@mariovavti.com> | 2018-07-25 10:19:19 +0200 |
---|---|---|
committer | Mario Vavti <mario@mariovavti.com> | 2018-07-25 10:19:19 +0200 |
commit | 1b1d11dcf1091158232e98abad966d4900e2ccc9 (patch) | |
tree | 380d5e04c73391089bf3d658ea4b27eecffa4916 /include/oembed.php | |
parent | b655d04b3474893ee3dea99b77f2e7dd764729a0 (diff) | |
parent | 35200e5f1b10cdd18af8f0ea646996e438b97011 (diff) | |
download | volse-hubzilla-1b1d11dcf1091158232e98abad966d4900e2ccc9.tar.gz volse-hubzilla-1b1d11dcf1091158232e98abad966d4900e2ccc9.tar.bz2 volse-hubzilla-1b1d11dcf1091158232e98abad966d4900e2ccc9.zip |
Merge branch '3.6RC'
Diffstat (limited to 'include/oembed.php')
-rwxr-xr-x | include/oembed.php | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/include/oembed.php b/include/oembed.php index e677087a2..41ab001d3 100755 --- a/include/oembed.php +++ b/include/oembed.php @@ -105,6 +105,7 @@ function oembed_action($embedurl) { // if the url is embeddable with oembed, return the bbcode link. function oembed_process($url) { + $j = oembed_fetch_url($url); logger('oembed_process: ' . print_r($j,true), LOGGER_DATA, LOG_DEBUG); if($j && $j['type'] !== 'error') @@ -132,6 +133,7 @@ function oembed_fetch_url($embedurl){ } } + $txt = null; // we should try to cache this and avoid a lookup on each render @@ -217,10 +219,19 @@ function oembed_fetch_url($embedurl){ } - $j = json_decode($txt,true); + if(strpos(strtolower($embedurl),'.pdf') !== false) { + $action = 'allow'; + $j = [ 'html' => '<object data="' . $embedurl . '" type="application/pdf" width="500" height="720">' . '<a href="' . $embedurl . '">' . t('View PDF') . '</a></object>', 'width' => 500, 'height' => 720, 'type' => 'pdf' ]; + + } - if(! $j) + if(! $j) { + $j = json_decode($txt,true); + } + + if(! $j) { $j = []; + } if($action === 'filter') { if($j['html']) { @@ -317,6 +328,11 @@ function oembed_format_object($j){ //$ret = "<a href='".$embedurl."'>".$j['title']."</a>"; }; break; + case 'pdf': { + $ret = $j['html']; + break; + } + case "rich": { // not so safe.. $ret.= $jhtml; |