Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/file/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
File 撇号CMS:如何访问小部件中上载的文件_File_Html5 Video_Apostrophe Cms - Fatal编程技术网

File 撇号CMS:如何访问小部件中上载的文件

File 撇号CMS:如何访问小部件中上载的文件,file,html5-video,apostrophe-cms,File,Html5 Video,Apostrophe Cms,我想建立一个视频小部件,当选择打开文件管理器对话框,用户可以选择一个本地视频,用户以前上传。有没有一个我可以研究的例子?然而,我想到了图像小部件,它包含许多功能,我只需要一个简单的文件选择器。我研究了这个小部件,并得出以下结论: 在lib/modules/localvideowidgets创建本地视频小部件 创建index.js文件: module.exports = { extend: 'apostrophe-widgets', name: 'local-video', label

我想建立一个视频小部件,当选择打开文件管理器对话框,用户可以选择一个本地视频,用户以前上传。有没有一个我可以研究的例子?然而,我想到了图像小部件,它包含许多功能,我只需要一个简单的文件选择器。

我研究了这个小部件,并得出以下结论:

  • 在lib/modules/localvideowidgets创建本地视频小部件

  • 创建index.js文件:

    module.exports = {
      extend: 'apostrophe-widgets',
      name: 'local-video',
      label: 'Local Video',
      addFields: [
        {
            name: 'filename',
            label: 'File',
            type: 'singleton',
            widgetType: 'apostrophe-files',
            options: {limit:1},
            required: true
        },
        {
            name: 'poster',
            label: 'Poster',
            type: 'singleton',
            widgetType: 'apostrophe-images',
            options: {limit:1},
            contextualOnly: true
        }        
      ],
    };
    
  • 在lib/modules/local video widgets/views/widget.html中创建视图:

    {% set vidFile = data.widget.filename.items[0]._pieces[0].attachment or null %}
    {% set vidPoster = data.widget.poster.items[0]._pieces[0].item.attachment or null %}
    
    <div class="video-wrapper">
        {% if vidPoster %}
            <video class="playRepeatVideo" id="highZoomVid"  width=100% controls controlsList="nodownload" poster="{{ apos.attachments.url(vidPoster) }}"> 
        {% else %}
            <video class="playRepeatVideo" id="highZoomVid"  width=100% controls controlsList="nodownload">
        {% endif %}
                <source src="{{ apos.attachments.url(vidFile) }}" type='video/mp4' > 
                <button id="play">&gt;</button>
                <button type="button" class="btn btn-primary">Primary</button>
            </video>     
    </div>
    
    {%set-vidFile=data.widget.filename.items[0]。\u-pieces[0]。附件或null%}
    {%set-vidPoster=data.widget.poster.items[0]。\u-pieces[0]。item.attachment或null%}
    {%if%}
    {%else%}
    {%endif%}
    主要的,重要的
    
  • 在app.js中注册小部件:

    模块:{
    “本地视频小部件”:{}
    }


  • 用户现在可以根据需要从本地文件系统浏览视频文件和视频海报图像。但是,我需要自定义文件选择器模式对话框

    我认为您可能遗漏了一两个步骤,以确保文件扩展名在上传时被撇号附件API接受。