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 | 4a86fa9b2e63b9d6bb0a07333d4c7d59df621270 (patch) | |
tree | 5770bd548bc70a10dbd5c24aee13c3449bf428a9 /mod/lightbox/thumbnail.php | |
parent | d7317abf01cc1f5a6e4ee54f25664e51d23217b9 (diff) | |
parent | 66dd3f3f5f14bb0ba6d2c7ef83b5b612d5ee2e30 (diff) | |
download | elgg-4a86fa9b2e63b9d6bb0a07333d4c7d59df621270.tar.gz elgg-4a86fa9b2e63b9d6bb0a07333d4c7d59df621270.tar.bz2 |
Merge commit '66dd3f3f5f14bb0ba6d2c7ef83b5b612d5ee2e30' as 'mod/lightbox'
Diffstat (limited to 'mod/lightbox/thumbnail.php')
-rw-r--r-- | mod/lightbox/thumbnail.php | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/mod/lightbox/thumbnail.php b/mod/lightbox/thumbnail.php new file mode 100644 index 000000000..aa6675f21 --- /dev/null +++ b/mod/lightbox/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; +} |