Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wordpress Gutenberg Media Upload Video Gallery

I want to have exactly the Media Upload Popup that is used when supplying the gallery attribute to the <MediaUpload> Component. Difference to normal Mediaupload is, that you see a sidebar on the left, and after selecting the items, you reach a view, where you can reorder media like in first image below, not like in the second one that appears with the code I am using:

<MediaUpload
  onSelect={ this.onSelectMedia }
  /*todo here should be gallery attr but it will disable video selection*/
  allowedTypes={ [ 'image', 'video' ] }
  accept="image/*,video/*"
  multiple
  value={ this.media.map( ( m ) => m.mediaId ) }
  render={ ( { open } ) => (
    <IconButton
      label={ __( 'Edit Media' ) }
      icon="images-alt2"
      onClick={ open }
    />
  ) }
/>

When I add the gallery attribute, the allowedTypes will somehow be overridden by the gallery attribute and only images will be shown in the MediaUpload Window.

First Image, how it is

enter image description here

Second Image, what i need (but with image + video showing)

enter image description here

like image 824
niklas Avatar asked Jun 11 '19 23:06

niklas


People also ask

How does WordPress media library work?

Access the WordPress Media Library by clicking Media on the WordPress admin dashboard. Upon accessing the Media Library page, you will see some options to browse files easily. First, choose how you want to view the media items in your library. Click on the list icon to activate the media library list view.


1 Answers

I think this has nothing to do with the MediaUpload component itself but with the underlying logic that wordpress only allows attachments of type image in its built-in gallery. As soon as you add the prop gallery to the component the media modal will default to the gallery edit frame. Maybe it’s possible to extend the gallery type to also allow other mime-types.

like image 173
Vortac Avatar answered Sep 25 '22 12:09

Vortac