Esempio n. 1
0
     break;
     // Create a cached thumbnail for a given image and return the thumbnail path
 // Create a cached thumbnail for a given image and return the thumbnail path
 case 'image':
     require_once '../classes/Pommo_Filesystem_Image.php';
     $imagePath = ltrim($_GET['image'], '/');
     $thumbWidth = 100;
     $thumbHeight = 100;
     if (!file_exists(IMAGE_DIRECTORY . $imagePath) || !is_file(IMAGE_DIRECTORY . $imagePath)) {
         // We don't want to output the $json array for this action, so just exit if an error occurs
         exit;
     }
     $oldImageObject = new Pommo_Filesystem_Image(IMAGE_DIRECTORY . $imagePath);
     $newImagePath = 'cache/' . mb_substr($imagePath, 0, strrpos($imagePath, '.')) . '-' . $thumbWidth . 'x' . $thumbHeight . '.' . $oldImageObject->getExtension();
     $newImageObject = new Pommo_Filesystem_File(ROOT_IMAGE_DIRECTORY . $newImagePath);
     if (!$newImageObject->exists() || $oldImageObject->getDateLastModified() > $newImageObject->getDateLastModified()) {
         $newImageObject->createAllDirectoriesInPath();
         $oldImageObject->resize($thumbWidth, $thumbHeight, true);
         $oldImageObject->save($newImageObject->getItemPath());
     }
     echo mb_substr($newImageObject->getItemPath(), 3);
     // Remove "../" for javascript
     exit;
     // Create a new directory in the given location
 // Create a new directory in the given location
 case 'create':
     $directory = '';
     if (isset($_POST['directory'])) {
         if (isset($_POST['name']) || $_POST['name']) {
             $directory = rtrim(IMAGE_DIRECTORY . $_POST['directory'], '/');
             if (!is_dir($directory)) {