diff options
author | Mario <mario@mariovavti.com> | 2018-01-09 09:00:20 +0100 |
---|---|---|
committer | Mario <mario@mariovavti.com> | 2018-01-09 09:00:20 +0100 |
commit | 4f4d0e416eac87121898b8a27b1afa6065ff17a2 (patch) | |
tree | aae7f2582b2b9c6596dcbf87c06a836434140830 /Zotlabs/Daemon/Thumbnail.php | |
parent | 22c89b6c660e185d5c5c6362acf23b145d932d15 (diff) | |
parent | 8fde0f01b8472082158b38386046ed606bcfbc49 (diff) | |
download | volse-hubzilla-4f4d0e416eac87121898b8a27b1afa6065ff17a2.tar.gz volse-hubzilla-4f4d0e416eac87121898b8a27b1afa6065ff17a2.tar.bz2 volse-hubzilla-4f4d0e416eac87121898b8a27b1afa6065ff17a2.zip |
Merge branch '3.0RC'3.0
Diffstat (limited to 'Zotlabs/Daemon/Thumbnail.php')
-rw-r--r-- | Zotlabs/Daemon/Thumbnail.php | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/Zotlabs/Daemon/Thumbnail.php b/Zotlabs/Daemon/Thumbnail.php new file mode 100644 index 000000000..e1f17c304 --- /dev/null +++ b/Zotlabs/Daemon/Thumbnail.php @@ -0,0 +1,78 @@ +<?php /** @file */ + +namespace Zotlabs\Daemon; + + +class Thumbnail { + + static public function run($argc,$argv) { + + if(! $argc == 2) + return; + + $c = q("select * from attach where hash = '%s' ", + dbesc($argv[1]) + ); + + if(! $c) + return; + + $attach = $c[0]; + + $preview_style = intval(get_config('system','thumbnail_security',0)); + $preview_width = intval(get_config('system','thumbnail_width',300)); + $preview_height = intval(get_config('system','thumbnail_height',300)); + + $p = [ + 'attach' => $attach, + 'preview_style' => $preview_style, + 'preview_width' => $preview_width, + 'preview_height' => $preview_height, + 'thumbnail' => null + ]; + + /** + * @hooks thumbnail + * * \e array \b attach + * * \e int \b preview_style + * * \e int \b preview_width + * * \e int \b preview_height + * * \e string \b thumbnail + */ + + call_hooks('thumbnail',$p); + if($p['thumbnail']) { + return; + } + + + $default_controller = null; + + $files = glob('Zotlabs/Thumbs/*.php'); + if($files) { + foreach($files as $f) { + $clsname = '\\Zotlabs\\Thumbs\\' . ucfirst(basename($f,'.php')); + if(class_exists($clsname)) { + $x = new $clsname(); + if(method_exists($x,'Match')) { + $matched = $x->Match($attach['filetype']); + if($matched) { + $x->Thumb($attach,$preview_style,$preview_width,$preview_height); + } + } + if(method_exists($x,'MatchDefault')) { + $default_matched = $x->MatchDefault(substr($attach['filetype'],0,strpos($attach['filetype'],'/'))); + if($default_matched) { + $default_controller = $x; + } + } + } + } + } + if(($default_controller) + && ((! file_exists(dbunescbin($attach['content']) . '.thumb')) + || (filectime(dbunescbin($attach['content']) . 'thumb') < (time() - 60)))) { + $default_controller->Thumb($attach,$preview_style,$preview_width,$preview_height); + } + } +} |