diff --git a/classes/controller.php b/classes/controller.php index cbe024284..764c0aa0a 100644 --- a/classes/controller.php +++ b/classes/controller.php @@ -349,7 +349,7 @@ protected function taskKeepAlive() protected function taskGetFilesInFolder() { if (!$this->authorizeTask('save', $this->dataPermissions())) { - return false; + return false; } $data = $this->view == 'pages' ? $this->admin->page(true) : $this->prepareData([]); @@ -374,7 +374,12 @@ protected function taskGetFilesInFolder() $folder = Folder::getRelativePath(rtrim($folder, '/')); $folder = $this->admin->getPagePathFromToken($folder); - $available_files = Folder::all($folder, ['recursive' => false]); + $media = new Media($folder); + $available_files = []; + + foreach ($media->all() as $name => $medium) { + $available_files[] = $name; + } // Peak in the flashObject for optimistic filepicker updates $pending_files = []; @@ -407,8 +412,8 @@ protected function taskGetFilesInFolder() $this->admin->json_response = [ 'status' => 'success', - 'files' => $available_files, - 'pending' => $pending_files, + 'files' => array_values($available_files), + 'pending' => array_values($pending_files), 'folder' => $folder ];