original_string: public static function thumbnail($filePath, $previewSize)
      {
          $filePath = normalizePath($filePath);
  
          if (!is_readable($filePath)) {
              return false;
          }
  
          $srcFileName = basename($filePath);
          $srcPath = dirname($filePath) . DS;
          $dstPath = normalizePath("{$srcPath}/.tmb/");
          $previewInfo = static::getPreviews($previewSize);
          require_once Plugin::classPath('Field') . 'Lib/class.upload.php';
          $handle = new \upload($srcPath . $srcFileName);
  
          if (empty($previewInfo)) {
              $previews = static::getPreviews();
              $previewInfo = reset($previews);
          }
  
          $dstFileNameBody = static::removeExt("{$previewInfo['width']}x{$previewInfo['height']}_{$srcFileName}");
          $dstFilePath = normalizePath("{$dstPath}/{$dstFileNameBody}.jpg");
  
          if (is_readable($dstFilePath)) {
              return $dstFilePath;
          }
  
          $handle->image_x = $previewInfo['width'];
          $handle->image_y = $previewInfo['height'];
          $handle->image_resize = true;
          $handle->image_ratio = false;
          $handle->image_ratio_crop = true;
          $handle->image_convert = 'jpg';
          $handle->file_new_name_body = $dstFileNameBody;
          $handle->process($dstPath);
  
          if (empty($handle->error)) {
              return $handle->file_dst_pathname;
          }
  
          return false;
      }
code: public static function thumbnail($filePath, $previewSize)
      {
          $filePath = normalizePath($filePath);
  
          if (!is_readable($filePath)) {
              return false;
          }
  
          $srcFileName = basename($filePath);
          $srcPath = dirname($filePath) . DS;
          $dstPath = normalizePath("{$srcPath}/.tmb/");
          $previewInfo = static::getPreviews($previewSize);
          require_once Plugin::classPath('Field') . 'Lib/class.upload.php';
          $handle = new \upload($srcPath . $srcFileName);
  
          if (empty($previewInfo)) {
              $previews = static::getPreviews();
              $previewInfo = reset($previews);
          }
  
          $dstFileNameBody = static::removeExt("{$previewInfo['width']}x{$previewInfo['height']}_{$srcFileName}");
          $dstFilePath = normalizePath("{$dstPath}/{$dstFileNameBody}.jpg");
  
          if (is_readable($dstFilePath)) {
              return $dstFilePath;
          }
  
          $handle->image_x = $previewInfo['width'];
          $handle->image_y = $previewInfo['height'];
          $handle->image_resize = true;
          $handle->image_ratio = false;
          $handle->image_ratio_crop = true;
          $handle->image_convert = 'jpg';
          $handle->file_new_name_body = $dstFileNameBody;
          $handle->process($dstPath);
  
          if (empty($handle->error)) {
              return $handle->file_dst_pathname;
          }
  
          return false;
      }
code_tokens: public static function thumbnail ( $ filePath , $ previewSize ) { $ filePath = normalizePath ( $ filePath ) ; if ( ! is_readable ( $ filePath ) ) { return false ; } $ srcFileName = basename ( $ filePath ) ; $ srcPath = dirname ( $ filePath ) . DS ; $ dstPath = normalizePath ( "{$srcPath}/.tmb/" ) ; $ previewInfo = static :: getPreviews ( $ previewSize ) ; require_once Plugin :: classPath ( 'Field' ) . 'Lib/class.upload.php' ; $ handle = new \ upload ( $ srcPath . $ srcFileName ) ; if ( empty ( $ previewInfo ) ) { $ previews = static :: getPreviews ( ) ; $ previewInfo = reset ( $ previews ) ; } $ dstFileNameBody = static :: removeExt ( "{$previewInfo['width']}x{$previewInfo['height']}_{$srcFileName}" ) ; $ dstFilePath = normalizePath ( "{$dstPath}/{$dstFileNameBody}.jpg" ) ; if ( is_readable ( $ dstFilePath ) ) { return $ dstFilePath ; } $ handle -> image_x = $ previewInfo [ 'width' ] ; $ handle -> image_y = $ previewInfo [ 'height' ] ; $ handle -> image_resize = true ; $ handle -> image_ratio = false ; $ handle -> image_ratio_crop = true ; $ handle -> image_convert = 'jpg' ; $ handle -> file_new_name_body = $ dstFileNameBody ; $ handle -> process ( $ dstPath ) ; if ( empty ( $ handle -> error ) ) { return $ handle -> file_dst_pathname ; } return false ; }
docstring: Creates a thumbnail for the given image.
  
  @param string $filePath Full path to original image file
  @param string $previewSize A valid preview preset
  @return false|string Full path to thumbnail file on success, false otherwise
docstring_tokens: Creates a thumbnail for the given image .