【问题标题】:How to add gallery functionality to WordPress block plugin如何将图库功能添加到 WordPress 块插件
【发布时间】:2020-09-24 23:41:36
【问题描述】:

我想将图库功能添加到 WP Gutenberg 块插件。使用媒体库轻松添加单个图像选项,但我不确定如何为图库添加元素,然后为您提供所有内置的 WordPress 标题功能和图库的拖放排序。很难找到包含此功能的教程。

我确实找到了一个插件,它可以做我想要的基础,但想要扩展块以包含其他字段。有问题的插件是getwid 滑块。

【问题讨论】:

    标签: wordpress wordpress-gutenberg gutenberg-blocks


    【解决方案1】:

    想通了。

    需要在 mediaupload 标签中添加 addToGallery=true 和 gallery=true。

    <MediaUpload
    	      			addToGallery={true}
    	                onSelect={(media) => {setAttributes({images: [...images, ...media]});}}
    	                type="image"
    	                multiple={true}
    	                gallery={true}
    	                value={images}
    	                render={({open}) => (
    	                    <Button className="slider-button select-images-button is-button is-default is-large" onClick={open}>
    	                        Add images
    	                    </Button>
    	                )}
    	            />

    【讨论】:

      猜你喜欢
      • 2012-08-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-11-12
      • 1970-01-01
      • 1970-01-01
      • 2017-02-25
      • 1970-01-01
      相关资源
      最近更新 更多