forked from rixtox/owncloud-thumbnail
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
46 lines (40 loc) · 1.07 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
/**
* ownCloud
*
* @author RixTox
* @copyright 2012 RixTox [email protected]
* @license WTFPL
* http://wtfpl2.com/
*
*/
/*
* Public app for generating thumbnails.
* Usage:
* Get thumbnail in default sizes:
* http://domain/owncloud/?app=files_thumbnail&
* path=/subdir/imagefile.jpg&size={xs, s, m, l, xl}
*
* Specify size for thumbnail:
* http://domain/owncloud/?app=files_thumbnail&
* path=/subdir/imagefile.jpg&width=125&height=125
*
*/
use OC\Thumbnail\ThumbnailManager as Thumbnail;
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('files_thumbnail');
session_write_close();
if(!empty($_GET['path'])) {
$filepath = $_GET['path'];
$filesize = empty($_GET['size'])?'':$_GET['size'];
$filewidth = empty($_GET['width'])?'':$_GET['width'];
$fileheight = empty($_GET['height'])?'':$_GET['height'];
$thumbnail = Thumbnail::getThumbnail($filepath, $filesize, $filewidth, $fileheight);
}
if (!empty($thumbnail)) {
OCP\Response::enableCaching(3600 * 24); // 24 hour
$thumbnail->show();
} else {
\OC_Response::setStatus(404);
exit();
}