Just so we understand better, can you give an example. What you expect and what you get
Sep 2, 2022
13
Level 6
Media file is displayed with firs character missing
For loading media using the Laravel Media Manager we have our own media controller. This is now working with latest flysystem 3 and Laravel 9 but for some reason the files are loading with first character missing. Any idea what inside the code could be causing this:
...
$list = [];
$dirList = $this->getFolderContent($dir);
$storageFolders = array_filter($this->getFolderListByType($dirList, 'dir'), [$this, 'ignoreFiles']);
$storageFiles = array_filter($this->getFolderListByType($dirList, 'file'), [$this, 'ignoreFiles']);
...
// files
foreach ($storageFiles as $file) {
if ($file['mimetype'] === 'image/webp') {
continue;
}
$path = $file['path'];
$time = $file['timestamp'] ?? null;
$data = [
'name' => $file['filename'].'.'.$file['extension'],
'type' => $file['mimetype'],
'size' => $file['size'],
'visibility' => $file['visibility'],
'path' => $this->resolveUrl($path),
'storage_path' => $path,
'last_modified' => $time,
'last_modified_formated' => $this->getItemTime($time),
];
...
and getFolderListByType is:
...
protected function getFolderListByType($list, $type)
{
$list = collect($list)->where('type', $type);
$sortBy = $list->pluck('basename')->values()->all();
$items = $list->values()->all();
array_multisort($sortBy, SORT_NATURAL, $items);
return $items;
}
..
Level 102
@rhand The problem seems to come when there are no / in the $path
Example
$path = 'foo.jpg';
$name = substr($path, strrpos($path, '/') + 1); //results in oo.jpg
1 like
Please or to participate in this conversation.