Skip to content

Commit a51a9fc

Browse files
committed
added image info with the response
1 parent 31696b6 commit a51a9fc

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

src/helpers.php

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ function getFileInfo(\Symfony\Component\Finder\SplFileInfo $file)
311311
{
312312
$path = request('path');
313313

314-
return [
314+
$info = [
315315
'name' => $file->getFilename(),
316316
'path' => sanitizePath($path.'/'.$file->getRelativePathname()),
317317
'is_dir' => $file->isDir(),
@@ -325,6 +325,22 @@ function getFileInfo(\Symfony\Component\Finder\SplFileInfo $file)
325325
'extension' => strtolower($file->getExtension()),
326326
'last_modified' => $file->getMTime(),
327327
];
328+
329+
if ($file->isFile()) {
330+
$mime = mimeTypes()->guessMimeType($file->getRealPath());
331+
if (preg_match('#^image/#', $mime)) {
332+
$dimension = getimagesize($file->getRealPath());
333+
$info['image_info'] = [
334+
'width' => $dimension['0'],
335+
'height' => $dimension['1'],
336+
'bits' => $dimension['bits'],
337+
'channels' => $dimension['channels'],
338+
'mime' => $dimension['mime'],
339+
];
340+
}
341+
}
342+
343+
return $info;
328344
}
329345

330346
/**

0 commit comments

Comments
 (0)