在 kartik-v/yii2-widget-fileinput 中显示视频缩略图

Showing video thumbnails in kartik-v/yii2-widget-fileinput

下面是我用于上传视频和图片的代码。图片预览在选择时显示,但当我 select 上传视频时,它会上传但不显示任何预览。

如果我遗漏了什么任何建议。

$form->field($model, 'sessionvideos')->widget(FileInput::classname(), [
        'options' => ['accept' => 'pdf', 'mp3', 'mp4', 'multiple' => true],
        'pluginOptions' => [
            'previewFileType' => 'any',
            'validateInitialCount' => true,
            'initialPreviewAsData' => true,
            'allowedFileExtensions' => ['pdf', 'mp3', 'mp4'],
            'maxFileCount' => 18,
            'showUpload' => false,
    ]]);

echo $form->field($model, 'video_file')->widget(FileInput::class, [
    'options'=>[
        'multiple'=>false,
        'accept'=>'video/*'
    ],
    'pluginOptions' => [
        'initialPreview'=> Yii::getAlias("@web/files/video.mp4"),
        'overwriteInitial'=>true,
        'showUpload' =>false,
        'allowedFileExtensions'=>['mp4'],
        'initialPreviewAsData'=>true,
        'initialPreviewFileType'=> 'video',
        'initialPreviewConfig'=> [
            ['filetype'=> "video/mp4"]
        ],
    ],
]);
echo $form->field($model, 'temp_video',[
'options' => [
    'tag' => 'div',
    'class' => 'form-group label-floating
'], 
'template' => '{label}{input}{error}{hint}'])->widget(FileInput::classname(), [
    'options' => ['multiple' => false,'accept' => 'video/*', 'class' => 'uploadImages'],
    'pluginOptions' => [
        'showCaption'=> false, 
        'dropZoneEnabled'=>false,
        'showCancel'=>false,
        'showRemove'=>false,
        'initialPreview'=> [ $model->image ? Yii::$app->urlManagerFrontEnd->createAbsoluteUrl(['uploads/news/'.$model->image]):''],
        'overwriteInitial'=>true,
        'showUpload' =>false,
        'allowedFileExtensions'=>['mp4', 'mpeg'],
        'initialPreviewAsData'=>true,
        'initialPreviewFileType'=> 'video',
        'initialPreviewConfig'=> [
            ['filetype'=> "video/mp4"],
            ['caption'=> $model->image ? $model->image : '']
        ],
    ],
])->label(false);