diff options
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; +} |