From c2feaa1bbed0831c4e4bf7d769f4e028b390fa2c Mon Sep 17 00:00:00 2001 From: Cash Costello Date: Sat, 12 Dec 2009 21:31:43 +0000 Subject: starting process of moving thumbnail to page handler --- pages/thumbnail.php | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 pages/thumbnail.php (limited to 'pages') diff --git a/pages/thumbnail.php b/pages/thumbnail.php new file mode 100644 index 000000000..3aad5969d --- /dev/null +++ b/pages/thumbnail.php @@ -0,0 +1,76 @@ +getSubtype() != "image") + forward('mod/tidypics/graphics/' . $error_image); + + // Get filename + if ($size == "thumb") { + $thumbfile = $file->thumbnail; + } else if ($size == "small") { + $thumbfile = $file->smallthumb; + } else { + $thumbfile = $file->largethumb; + } + + if (!$thumbfile) + forward('mod/tidypics/graphics/' . $error_image); + + // create Elgg File object + $readfile = new ElggFile(); + $readfile->owner_guid = $file->owner_guid; + $readfile->setFilename($thumbfile); + $contents = $readfile->grabFile(); + + // send error image if file could not be read + if (!$contents) { + forward('mod/tidypics/graphics/' . $error_image); + } + + // expires every 14 days + $expires = 14 * 60*60*24; + + // overwrite header caused by php session code so images can be cached + $mime = $file->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; + \ No newline at end of file -- cgit v1.2.3