]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
starting process of moving thumbnail to page handler
authorCash Costello <cash.costello@gmail.com>
Sat, 12 Dec 2009 21:31:43 +0000 (21:31 +0000)
committerCash Costello <cash.costello@gmail.com>
Sat, 12 Dec 2009 21:31:43 +0000 (21:31 +0000)
pages/thumbnail.php [new file with mode: 0644]
start.php

diff --git a/pages/thumbnail.php b/pages/thumbnail.php
new file mode 100644 (file)
index 0000000..3aad596
--- /dev/null
@@ -0,0 +1,76 @@
+<?php
+
+       /**
+        * Tidypics Thumbnail
+        * 
+        */
+       
+       // Get file GUID
+       $file_guid = (int) get_input('file_guid');
+       
+       // Get file thumbnail size
+       $size = get_input('size');
+       // only 3 possibilities
+       if ($size != 'small' && $size != 'thumb') {
+               $size = 'large';
+       }
+       
+       $error_image = '';
+       switch ($size) {
+               case 'thumb':
+                       $error_image = "image_error_thumb.png";
+                       break;
+               case 'small':
+                       $error_image = "image_error_small.png";
+                       break;
+               case 'large':
+                       $error_image = "image_error_large.png";
+                       break;
+       }
+       
+       // Get file entity
+       $file = get_entity($file_guid);
+       if (!$file)
+               forward('mod/tidypics/graphics/' . $error_image);
+       
+       if ($file->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
index 472bf48814cd527eeeb1e6c03794a56a510cf367..f2732b3de34b695feb8193bd8df245cb7729993f 100644 (file)
--- a/start.php
+++ b/start.php
                                        include($CONFIG->pluginspath . "tidypics/pages/download.php");
                                break;
                                
+                               case "thumbnail": // tidypics thumbnail
+                                       if (isset($page[1])) set_input('file_guid', $page[1]);
+                                       if (isset($page[2])) set_input('size', $page[2]);
+                                       include($CONFIG->pluginspath . "tidypics/pages/thumbnail.php");
+                               break;
+                               
                                case "tagged": // all photos tagged with user 
                                        if (isset($page[1])) set_input('guid',$page[1]);
                                        include($CONFIG->pluginspath . "tidypics/pages/tagged.php");