WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
10.52k stars 4.21k forks source link

`MediaUpload` `gallery` + `allowedTypes` attributes do not work as documented in combination #53619

Open thenadz opened 1 year ago

thenadz commented 1 year ago

Description

The MediaUpload component gallery and allowedTypes attributes do not function as documented when used in combination. If gallery is used, effective allowedTypes appears to always be image.

This forces major development efforts to replicate the same functionality where other file types are in play, as with Document Gallery for example.

Step-by-step reproduction instructions

  1. Create MediaUpload element with below configuration and non-image files available. Confirm that the available files in dialog are exclusively images.

    <MediaUpload
    gallery={true}
    allowedTypes='application,video,text,audio,image'
    render={({open}) => (
      <Button
          variant='secondary'
          onClick={open}
      >
          Select files
      </Button>
    )}
    />
  2. Create MediaUpload element with below configuration and non-image files available. Confirm that all files are displayed in dialog.

    <MediaUpload
    allowedTypes='application,video,text,audio,image'
    render={({open}) => (
      <Button
          variant='secondary'
          onClick={open}
      >
          Select files
      </Button>
    )}
    />

Screenshots, screen recording, code snippet

No response

Environment info

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

jorgefilipecosta commented 1 year ago

Thank you @thenadz for reporting this issue. I was able to replicate it.