mirror of
https://github.com/getgrav/grav.git
synced 2026-03-06 20:41:36 +01:00
use FilesystemIterator to solve windows path issue more elegantly
This commit is contained in:
@@ -40,14 +40,14 @@ class Media extends Getters
|
||||
|
||||
$this->path = $path;
|
||||
|
||||
$iterator = new \DirectoryIterator($path);
|
||||
$iterator = new \FilesystemIterator($path, \FilesystemIterator::UNIX_PATHS | \FilesystemIterator::SKIP_DOTS);
|
||||
|
||||
$media = [];
|
||||
|
||||
/** @var \DirectoryIterator $info */
|
||||
foreach ($iterator as $info) {
|
||||
foreach ($iterator as $path => $info) {
|
||||
// Ignore folders and Markdown files.
|
||||
if ($info->isDot() || !$info->isFile() || $info->getExtension() == 'md') {
|
||||
if (!$info->isFile() || $info->getExtension() == 'md') {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -58,9 +58,9 @@ class Media extends Getters
|
||||
|
||||
if ($type === 'alternative') {
|
||||
$media["{$basename}.{$ext}"][$type] = isset($media["{$basename}.{$ext}"][$type]) ? $media["{$basename}.{$ext}"][$type] : [];
|
||||
$media["{$basename}.{$ext}"][$type][$extra] = str_replace(DIRECTORY_SEPARATOR, DS, $info->getPathname());
|
||||
$media["{$basename}.{$ext}"][$type][$extra] = $path;
|
||||
} else {
|
||||
$media["{$basename}.{$ext}"][$type] = str_replace(DIRECTORY_SEPARATOR, DS, $info->getPathname());
|
||||
$media["{$basename}.{$ext}"][$type] = $path;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user