You are here

public function FileCommited::getSizes in N1ED - Visual editor as CKEditor plugin with Bootstrap support 8.2

Gets sizes of image.

File

src/Flmngr/FileUploaderServer/lib/file/FileCommited.php, line 149

Class

FileCommited
Commited file (data structure about the file of finished upload transaction). Has method for resizing images (applying sizes when finishing transaction).

Namespace

Drupal\n1ed\Flmngr\FileUploaderServer\lib\file

Code

public function getSizes() {
  $thisFileFullPath = $this
    ->getFullPath();
  $thisName = $this
    ->getNameWithoutExt();
  $thisFileDir = dirname($this);
  $files = array_diff(scandir($thisFileDir), [
    '..',
    '.',
  ]);
  $sizes = [];
  for ($i = 0; $i < count($files); $i++) {
    $file = $files[$i];
    $name = basename($file);
    $ext = Utils::getExt($name);
    if ($ext != NULL) {
      $name = substr($name, 0, strlen($name) - strlen($ext) - 1);
    }
    if ($thisFileFullPath !== $file && strpos($name, $thisName . "-") === 0) {
      $sizes[] = substr($name, strlen($thisName) + 1);
    }
  }
  return $sizes;
}