diff options
Diffstat (limited to 'mod/lightpics/pages/photos/image/thumbnail.php')
-rw-r--r-- | mod/lightpics/pages/photos/image/thumbnail.php | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/mod/lightpics/pages/photos/image/thumbnail.php b/mod/lightpics/pages/photos/image/thumbnail.php new file mode 100644 index 000000000..28fabf7aa --- /dev/null +++ b/mod/lightpics/pages/photos/image/thumbnail.php @@ -0,0 +1,38 @@ +<?php +/** + * Image thumbnail view + * + * @author Cash Costello + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License v2 + */ + +$guid = (int) get_input('guid'); +$size = get_input('size'); +$image = get_entity($guid); +if (!$image) { + // @todo +} + +if ($size == 'master') { + $contents = $image->getImage(); +} else { + $contents = $image->getThumbnail($size); +} +if (!$contents) { + forward("mod/lightpics/graphics/image_error_$size"); +} + +// expires every 14 days +$expires = 14 * 60*60*24; + +// overwrite header caused by php session code so images can be cached +$mime = $image->getMimeType(); +header("Content-Type: $mime"); +header("Content-Length: " . strlen($contents)); +header("Cache-Control: public", true); +header("Pragma: public", true); +header('Expires: ' . gmdate('D, d M Y H:i:s', time() + $expires) . ' GMT', true); + +// Return the thumbnail and exit +echo $contents; +exit; |