mkdir($foldercheck); } } else { $tsuff = ''; } $last = strrpos($image, "/"); $name = substr($image, $last + 1); $ext = strrchr($name, '.'); $thumb = substr($name, 0, -strlen($ext)); $newtb = "images/stories/mod_aidanews_thumbs/" . $tsuff . $thumb . ".jpg"; if (file_exists($newtb)) { } else { $tb = new ThumbAndCrop(); $tb->openImg($image); if ($imageHeight && empty($imageWidth)) { $newWidth = $tb->getRightWidth($imageHeight); $tb->creaThumb($newWidth, $imageHeight); } elseif (empty($imageHeight) && $imageWidth) { $newHeight = $tb->getRightHeight($imageWidth); $tb->creaThumb($imageWidth, $newHeight); } elseif ($imageHeight && $imageWidth) { $newWidth = $tb->getRightWidth($imageHeight); $newHeight = $tb->getRightHeight($imageWidth); if ($newWidth > $imageWidth) { $subWidth = ($newWidth - $imageWidth) / 2; $tb->creaThumb($newWidth, $imageHeight); $tb->setThumbAsOriginal(); $tb->cropThumb($imageWidth, $imageHeight, $subWidth, 0); } elseif ($newWidth == $imageWidth) { $tb->creaThumb($imageWidth, $imageHeight); } elseif ($newWidth < $imageWidth) {