diff options
Diffstat (limited to 'pages/photos/image/thumbnail.php')
-rw-r--r-- | pages/photos/image/thumbnail.php | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/pages/photos/image/thumbnail.php b/pages/photos/image/thumbnail.php new file mode 100644 index 000000000..ae07f2706 --- /dev/null +++ b/pages/photos/image/thumbnail.php @@ -0,0 +1,34 @@ +<?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 +} + +$contents = $image->getThumbnail($size); +if (!$contents) { + forward("mod/tidypics/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; |