aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCash Costello <cash.costello@gmail.com>2009-06-20 16:33:54 +0000
committerCash Costello <cash.costello@gmail.com>2009-06-20 16:33:54 +0000
commit72278f3d3ce9b3dff0b4f5e95ad400d14a79eb71 (patch)
tree9791eb081f191af7986c5c191657cc8a20157b3b
parent2edd32906e7bdbe623a37e1848a8096a4001acc0 (diff)
downloadelgg-72278f3d3ce9b3dff0b4f5e95ad400d14a79eb71.tar.gz
elgg-72278f3d3ce9b3dff0b4f5e95ad400d14a79eb71.tar.bz2
cleaned up the thumbnail code
-rw-r--r--thumbnail.php66
1 files changed, 35 insertions, 31 deletions
diff --git a/thumbnail.php b/thumbnail.php
index fe8ca8bab..113262960 100644
--- a/thumbnail.php
+++ b/thumbnail.php
@@ -5,46 +5,50 @@
*
*/
- // Get engine
include_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");
-
+
// Get file GUID
- $file_guid = (int) get_input('file_guid',0);
-
+ $file_guid = (int) get_input('file_guid');
+
// Get file thumbnail size
- $size = get_input('size','small');
+ $size = get_input('size');
+ // only 3 possibilities
if ($size != 'small' && $size != 'thumb') {
$size = 'large';
}
-
+ error_log('size is ' . $size);
+
// Get file entity
- if ($file = get_entity($file_guid)) {
- if ($file->getSubtype() == "image") {
- // Get file thumbnail
- if ($size === "thumb") {
- $thumbfile = $file->thumbnail;
- } else if ($size === "small") {
- $thumbfile = $file->smallthumb;
- } else {
- $thumbfile = $file->largethumb;
- }
-
- // 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();
- }
- } //end subtype comparison
- } //end get_entity
+ $file = get_entity($file_guid);
+ if (!$file)
+ forward('mod/tidypics/graphics/img_error.jpg');
+
+ if ($file->getSubtype() != "image")
+ forward('mod/tidypics/graphics/img_error.jpg');
+
+ // Get filename
+ if ($size == "thumb") {
+ $thumbfile = $file->thumbnail;
+ } else if ($size == "small") {
+ $thumbfile = $file->smallthumb;
+ } else {
+ $thumbfile = $file->largethumb;
+ }
+ error_log('filename is ' . $thumbfile);
+
+ if (!$thumbfile)
+ forward('mod/tidypics/graphics/img_error.jpg');
+
+ // create Elgg File object
+ $readfile = new ElggFile();
+ $readfile->owner_guid = $file->owner_guid;
+ $readfile->setFilename($thumbfile);
+ $contents = $readfile->grabFile();
- // Open error image if file was not found
- if (!isset($contents) || is_null($contents) || $file->getSubtype()!='image') {
- //$vars['url'].'mod/tidypics/graphics/img_error.jpg
+ // send error image if file could not be read
+ if (!$contents) {
forward('mod/tidypics/graphics/img_error.jpg');
- } //end of default error image
+ }
// Return the thumbnail and exit
header("Content-type: image");