pdf embeds
This commit is contained in:
parent
257dcaaf8b
commit
e646684493
@ -82,6 +82,10 @@ class Linkinfo extends \Zotlabs\Web\Controller {
|
|||||||
echo $br . '[audio]' . $url . '[/audio]' . $br;
|
echo $br . '[audio]' . $url . '[/audio]' . $br;
|
||||||
killme();
|
killme();
|
||||||
}
|
}
|
||||||
|
if(strtolower($type) === 'application/pdf' || strtolower($type) === 'application/x-pdf') {
|
||||||
|
echo $br . '[embed]' . $url . '[/embed]' . $br;
|
||||||
|
killme();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,6 +105,7 @@ function oembed_action($embedurl) {
|
|||||||
// if the url is embeddable with oembed, return the bbcode link.
|
// if the url is embeddable with oembed, return the bbcode link.
|
||||||
|
|
||||||
function oembed_process($url) {
|
function oembed_process($url) {
|
||||||
|
|
||||||
$j = oembed_fetch_url($url);
|
$j = oembed_fetch_url($url);
|
||||||
logger('oembed_process: ' . print_r($j,true), LOGGER_DATA, LOG_DEBUG);
|
logger('oembed_process: ' . print_r($j,true), LOGGER_DATA, LOG_DEBUG);
|
||||||
if($j && $j['type'] !== 'error')
|
if($j && $j['type'] !== 'error')
|
||||||
@ -132,6 +133,7 @@ function oembed_fetch_url($embedurl){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$txt = null;
|
$txt = null;
|
||||||
|
|
||||||
// we should try to cache this and avoid a lookup on each render
|
// 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 = [];
|
$j = [];
|
||||||
|
}
|
||||||
|
|
||||||
if($action === 'filter') {
|
if($action === 'filter') {
|
||||||
if($j['html']) {
|
if($j['html']) {
|
||||||
@ -317,6 +328,11 @@ function oembed_format_object($j){
|
|||||||
|
|
||||||
//$ret = "<a href='".$embedurl."'>".$j['title']."</a>";
|
//$ret = "<a href='".$embedurl."'>".$j['title']."</a>";
|
||||||
}; break;
|
}; break;
|
||||||
|
case 'pdf': {
|
||||||
|
$ret = $j['html'];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case "rich": {
|
case "rich": {
|
||||||
// not so safe..
|
// not so safe..
|
||||||
$ret.= $jhtml;
|
$ret.= $jhtml;
|
||||||
|
Reference in New Issue
Block a user