我想在前端显示 Laravel Voyager 存储的多个视频, 我正在尝试使用以下命令提取通过管理员上传的视频:
@foreach ($videos as $video)
<video width="320" height="240" controls>
<source src="{{ Voyager::image( $video->file) }}" type="video/mp4">
</video>
@endforeach
但是不行,有人可以帮忙吗?
您可以像这样直接从存储中调用它:
@foreach ($videos as $video)
<video width="320" height="240" controls>
<source src="{{ Storage::url($video->file) }}" type="video/mp4">
// Or
<source src="{{ asset("storage/$video->file") }}" type="video/mp4">
</video>
@endforeach
@php // 解码 JSON 字段 $fileInfo = json_decode($model->file_column, true); @endphp
@if ($fileInfo && isset($fileInfo[0]['download_link'])) 您的浏览器不支持视频标签。 @endif