function createThumb($iTSize, $bSquare = true, $bForce = false, $strThumbPath = false) { if (!$strThumbPath) { $objThumb = new PImage(CACHE_DIR . "thumbnails/" . $iTSize . "x" . $iTSize . "/" . $this->getRelativePath()); } else { $objThumb = new PImage($strThumbPath); } //if objThumb exists if (is_file($objThumb->path)) { if (!$bForce) { return $objThumb; } else { if (!$objThumb->Delete()) { return false; } } } //create the directory $oDirParent = new PDir($objThumb->getParentPath()); if (!is_dir($oDirParent->path) && !$oDirParent->mkdir()) { return false; } if (!$this->Copy($this->getName(), $oDirParent->path)) { return false; } if (!$objThumb->ResizeMax($iTSize, $bSquare)) { $objThumb->Delete(); //if error occured while resizing thumb, delete it. return false; } return $objThumb; }