aboutsummaryrefslogtreecommitdiffstats
path: root/apps/gallery/ajax
diff options
context:
space:
mode:
authorBart Visscher <bartv@thisnet.nl>2012-02-07 22:33:47 +0100
committerBart Visscher <bartv@thisnet.nl>2012-02-08 21:12:30 +0100
commit43d2266f5ca9f9f2802bf131fddeb21f849f3d12 (patch)
treeeb3a04deba6482005e1ddc7b1eceae03c0ee37a3 /apps/gallery/ajax
parenteb5de4d4f7b98bb1c258dbb5ed5ecf9c2d39e746 (diff)
downloadnextcloud-server-43d2266f5ca9f9f2802bf131fddeb21f849f3d12.tar.gz
nextcloud-server-43d2266f5ca9f9f2802bf131fddeb21f849f3d12.zip
Add caching to gallery thumbnail generation
Diffstat (limited to 'apps/gallery/ajax')
-rw-r--r--apps/gallery/ajax/thumbnail.php24
1 files changed, 8 insertions, 16 deletions
diff --git a/apps/gallery/ajax/thumbnail.php b/apps/gallery/ajax/thumbnail.php
index ad91edfa3c8..2dfe936d9dd 100644
--- a/apps/gallery/ajax/thumbnail.php
+++ b/apps/gallery/ajax/thumbnail.php
@@ -25,22 +25,14 @@ require_once('../../../lib/base.php');
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('gallery');
-$box_size = 200;
$img = $_GET['img'];
-$imagePath = OC_Filesystem::getLocalFile($img);
-
-if(file_exists($imagePath)) {
- $image = new OC_Image($imagePath);
- $image->centerCrop();
- $image->resize($box_size, $box_size);
- $image->fixOrientation();
-
- $offset = 3600 * 24;
- // calc the string in GMT not localtime and add the offset
- header("Expires: " . gmdate("D, d M Y H:i:s", time() + $offset) . " GMT");
- header('Cache-Control: max-age='.$offset.', must-revalidate');
- header('Pragma: public');
-
- $image->show();
+$image = OC_Gallery_Photo::getThumbnail($img);
+if ($image) {
+ $offset = 3600 * 24; // 24 hour
+ // calc the string in GMT not localtime and add the offset
+ header("Expires: " . gmdate("D, d M Y H:i:s", time() + $offset) . " GMT");
+ header('Cache-Control: max-age='.$offset.', must-revalidate');
+ header('Pragma: public');
+ $image->show();
}