Skip to content

Commit eb9afba

Browse files
authored
Update FileManagerService.php
1 parent 8f33dac commit eb9afba

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/Service/FileManagerService.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,24 @@ public function getFiles(string $path = '/', string|null $depth = '== 0'): array
537537
return $fileList;
538538
}
539539

540+
public function getImageSize(string $filePath, bool $absolute = false): ?array
541+
{
542+
if ($absolute) {
543+
$imageSize = @getimagesize($filePath);
544+
} else {
545+
$imageSize = @getimagesize($this->getKernelDirectory() . $filePath);
546+
}
547+
548+
if ($imageSize) {
549+
return [
550+
'width' => $imageSize[0] ?? null,
551+
'height' => $imageSize[1] ?? null
552+
];
553+
} else {
554+
return null;
555+
}
556+
}
557+
540558
private function getFileInfo(SplFileInfo $file): array
541559
{
542560
$filePath = $file->getRealPath();

0 commit comments

Comments
 (0)