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

tjjdgumg  于 2022-11-09  发布在  其他
关注(0)|答案(2)|浏览(165)

下面是我上传视频和图片的代码。图片预览显示在selection上,但当我选择上传视频时,它会上传,但不显示任何预览。
如果我错过了什么,有什么建议吗?

$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,
    ]]);
jv4diomz

jv4diomz1#

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);
1cklez4t

1cklez4t2#

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"]
        ],
    ],
]);

相关问题