Skip to content

Commit b6ce0a4

Browse files
committed
fixed files list
1 parent cde22e8 commit b6ce0a4

File tree

3 files changed

+19
-7
lines changed

3 files changed

+19
-7
lines changed

src/Plugins/Core.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,20 @@ public function list()
1717
$dirs = fm_finder()->depth(0)->directories()->in(fm_request_path());
1818
$files = fm_finder()->depth(0)->files()->in(fm_request_path());
1919

20+
// check if there are any search results
2021
$list = [
2122
'dirs' => [],
2223
'files' => [],
2324
];
25+
2426
/** @var SplFileInfo $dir */
2527
foreach ($dirs as $dir) {
2628
$list['dirs'][] = fm_getFileInfo($dir);
2729
}
30+
2831
/** @var SplFileInfo $file */
2932
foreach ($files as $file) {
30-
$list['files'][] = fm_getFileInfo($file);
33+
$list['files'][] = fm_getFileInfo($file, 'files');
3134
}
3235
$filtered_list = fm_apply_filter('core@list', $list);
3336

src/config.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@
1010
],
1111
'plugins' => [
1212
'core' => \ThemeXpert\FileManager\Plugins\Core::class,
13-
'pjpeg' => \ThemeXpert\FileManager\Plugins\ProgressiveJPEG::class,
13+
// 'pjpeg' => \ThemeXpert\FileManager\Plugins\ProgressiveJPEG::class,
1414
]
1515
];

src/helpers.php

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,13 @@ function fm_add_filter($hook, $callable)
6969
function fm_apply_filter($hook, $value)
7070
{
7171
global $filters;
72+
if($filters && $filters[$hook] !== null){
73+
return array_reduce($filters[$hook], function ($value, $filter) {
74+
return $filter($value);
75+
}, $value);
76+
}
7277

73-
return array_reduce($filters[$hook], function ($value, $filter) {
74-
return $filter($value);
75-
}, $value);
78+
return $value;
7679
}
7780

7881
/**
@@ -388,11 +391,12 @@ function fm_abort($code, $data = ['message' => 'Aborted'])
388391

389392
/**
390393
* @param \Symfony\Component\Finder\SplFileInfo $file
394+
* @param string $type
391395
*
392396
* @return array
393397
* @since 1.0.0
394398
*/
395-
function fm_getFileInfo(\Symfony\Component\Finder\SplFileInfo $file)
399+
function fm_getFileInfo(\Symfony\Component\Finder\SplFileInfo $file, $type = 'dirs')
396400
{
397401
$path = fm_request('path');
398402

@@ -412,7 +416,12 @@ function fm_getFileInfo(\Symfony\Component\Finder\SplFileInfo $file)
412416
'extra' => [],
413417
];
414418

415-
if ($file->isFile()) {
419+
/**
420+
* previously was $file->isFile()
421+
* now added as params
422+
* @since 1.3.0
423+
*/
424+
if ($type === 'files') {
416425
$mime = fm_mimeTypes()->guessMimeType($file->getRealPath());
417426
if (preg_match('#^image/#', $mime)) {
418427
$dimension = getimagesize($file->getRealPath());

0 commit comments

Comments
 (0)