aboutsummaryrefslogtreecommitdiff
path: root/mod/file/thumbnail.php
diff options
context:
space:
mode:
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-03-03 17:53:05 +0000
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-03-03 17:53:05 +0000
commit4766f36a4d74924f21ff329c4318ce4e069ffa04 (patch)
tree969b84632f2a8b0db79788a8a6db8e41d63e5cb4 /mod/file/thumbnail.php
parent57a217fd6b708844407486046a1faa23b46cac08 (diff)
downloadelgg-4766f36a4d74924f21ff329c4318ce4e069ffa04.tar.gz
elgg-4766f36a4d74924f21ff329c4318ce4e069ffa04.tar.bz2
Pulled in the interface changes.
git-svn-id: http://code.elgg.org/elgg/trunk@5257 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'mod/file/thumbnail.php')
-rw-r--r--mod/file/thumbnail.php69
1 files changed, 69 insertions, 0 deletions
diff --git a/mod/file/thumbnail.php b/mod/file/thumbnail.php
new file mode 100644
index 000000000..a150cce5a
--- /dev/null
+++ b/mod/file/thumbnail.php
@@ -0,0 +1,69 @@
+<?php
+
+/**
+ * Elgg file thumbnail
+ *
+ * @package ElggFile
+ * @author Curverider Ltd
+ * @copyright Curverider Ltd 2008-2010
+ * @link http://elgg.com/
+ */
+
+// Get engine
+require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");
+
+// Get file GUID
+$file_guid = (int) get_input('file_guid',0);
+
+// Get file thumbnail size
+$size = get_input('size','small');
+
+// Get file entity
+if ($file = get_entity($file_guid)) {
+
+ if ($file->getSubtype() == "file") {
+
+ $simpletype = $file->simpletype;
+ if ($simpletype == "image") {
+
+ // Get file thumbnail
+ switch ($size) {
+ case "small":
+ $thumbfile = $file->thumbnail;
+ break;
+ case "medium":
+ $thumbfile = $file->smallthumb;
+ break;
+ case "large":
+ default:
+ $thumbfile = $file->largethumb;
+ break;
+ }
+
+ // Grab the file
+ if ($thumbfile && !empty($thumbfile)) {
+ $readfile = new ElggFile();
+ $readfile->owner_guid = $file->owner_guid;
+ $readfile->setFilename($thumbfile);
+ $mime = $file->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;
+
+ }
+
+ }
+
+ }
+
+}
+
+?> \ No newline at end of file