You are here

private static function FlmngrServer::reqFileResize in N1ED - Visual editor as CKEditor plugin with Bootstrap support 8.2

Processes a request for resiging image. Used for creating previews for galleries and responsive images.

1 call to FlmngrServer::reqFileResize()
FlmngrServer::flmngrRequest in src/Flmngr/FlmngrServer/FlmngrServer.php
Processes a request to file manager.

File

src/Flmngr/FlmngrServer/FlmngrServer.php, line 421

Class

FlmngrServer
File Manager server. This is a entry point for processing any of incoming Flmngr client's request. It takes "action" parameter from request and decides which request processor to use and executes it, then returns a result as…

Namespace

Drupal\n1ed\Flmngr\FlmngrServer

Code

private static function reqFileResize($config) {
  $filePath = $_POST['f'];
  $newFileNameWithoutExt = $_POST['n'];
  $maxWidth = $_POST['mw'];
  $maxHeight = $_POST['mh'];
  $mode = $_POST['mode'];
  try {
    $fileSystem = new FMDiskFileSystem($config);
    $resizedFilePath = $fileSystem
      ->resizeFile($filePath, $newFileNameWithoutExt, $maxWidth, $maxHeight, $mode);
    return new Response(NULL, $resizedFilePath);
  } catch (MessageException $e) {
    return new Response($e
      ->getFailMessage(), NULL);
  }
}