diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2014-03-15 15:04:14 -0300 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2014-03-15 15:04:14 -0300 |
commit | 66dd3f3f5f14bb0ba6d2c7ef83b5b612d5ee2e30 (patch) | |
tree | 6002cbd9db40b15b4e67a67d5669644f86e4dbde /thumbnail.php | |
download | elgg-66dd3f3f5f14bb0ba6d2c7ef83b5b612d5ee2e30.tar.gz elgg-66dd3f3f5f14bb0ba6d2c7ef83b5b612d5ee2e30.tar.bz2 |
Squashed 'mod/lightbox/' content from commit a83b8d8
git-subtree-dir: mod/lightbox
git-subtree-split: a83b8d89691c31b4568f47790fb40d0bc962aca5
Diffstat (limited to 'thumbnail.php')
-rw-r--r-- | thumbnail.php | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/thumbnail.php b/thumbnail.php new file mode 100644 index 000000000..aa6675f21 --- /dev/null +++ b/thumbnail.php @@ -0,0 +1,55 @@ +<?php +/** + * Elgg image thumbnail + * + * @package ElggLightbox + */ + +// Get engine +require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php"); + +// Get entity GUID +$guid = (int) get_input('guid', 0); + +// Get thumbnail size +$size = get_input('size', 'small'); + +// Get image or album cover +$entity = new LightboxPluginImage($guid); +if (!$entity->guid) { + exit; +} + + +// Get entity thumbnail +switch ($size) { + case "small": + $thumb = $entity->thumbnail; + break; + case "medium": + $thumb = $entity->smallthumb; + break; + case "large": + default: + $thumb = $entity->largethumb; + break; +} + +// Grab the file +if ($thumb && !empty($thumb)) { + $readfile = new ElggFile(); + $readfile->owner_guid = $entity->owner_guid; + $readfile->setFilename($thumb); + $mime = $entity->getMimeType(); + $contents = $readfile->grabFile(); + + // caching images for 10 days + header("Content-type: $mime"); + header('Expires: ' . date('r',time() + 864000)); + header("Pragma: public", true); + header("Cache-Control: public", true); + header("Content-Length: " . strlen($contents)); + + echo $contents; + exit; +} |