optimise oembed pdf processing so we do not actually load the content, which could cause performance issues. ported from zap.
This commit is contained in:
parent
769195fcff
commit
7465c79884
@ -1,6 +1,6 @@
|
||||
<?php /** @file */
|
||||
|
||||
use Zotlabs\Lib as Zlib;
|
||||
use Zotlabs\Lib\Cache;
|
||||
|
||||
|
||||
function oembed_replacecb($matches){
|
||||
@ -133,7 +133,6 @@ function oembed_fetch_url($embedurl){
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$txt = null;
|
||||
|
||||
// we should try to cache this and avoid a lookup on each render
|
||||
@ -143,8 +142,20 @@ function oembed_fetch_url($embedurl){
|
||||
|
||||
$furl = ((local_channel() && $zrl) ? zid($embedurl) : $embedurl);
|
||||
|
||||
if($action !== 'block') {
|
||||
$txt = Zlib\Cache::get('[' . App::$videowidth . '] ' . $furl);
|
||||
if($action !== 'block' && (! get_config('system','oembed_cache_disable'))) {
|
||||
$txt = Cache::get('[' . App::$videowidth . '] ' . $furl);
|
||||
}
|
||||
|
||||
if(strpos(strtolower($embedurl),'.pdf') !== false) {
|
||||
$action = 'allow';
|
||||
$j = [
|
||||
'html' => '<object data="' . $embedurl . '" type="application/pdf" style="width: 100%; height: 300px;"></object>',
|
||||
'title' => t('View PDF'),
|
||||
'type' => 'pdf'
|
||||
];
|
||||
|
||||
// set $txt to something so that we don't attempt to fetch what could be a lengthy pdf.
|
||||
$txt = EMPTY_STR;
|
||||
}
|
||||
|
||||
if(is_null($txt)) {
|
||||
@ -215,17 +226,7 @@ function oembed_fetch_url($embedurl){
|
||||
// save in cache
|
||||
|
||||
if(! get_config('system','oembed_cache_disable'))
|
||||
Zlib\Cache::set('[' . App::$videowidth . '] ' . $furl, $txt);
|
||||
|
||||
}
|
||||
|
||||
if(strpos(strtolower($embedurl),'.pdf') !== false) {
|
||||
$action = 'allow';
|
||||
$j = [
|
||||
'html' => '<object data="' . $embedurl . '" type="application/pdf" style="width: 100%; height: 300px;"></object>',
|
||||
'title' => t('View PDF'),
|
||||
'type' => 'pdf'
|
||||
];
|
||||
Cache::set('[' . App::$videowidth . '] ' . $furl, $txt);
|
||||
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user