Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/fields/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ _Parameters_
- _props.data_ `Item`: - The item being edited.
- _props.field_ `Object`: - The field configuration with getValue and setValue methods.
- _props.onChange_ `Function`: - Callback function when the media selection changes.
- _props.allowedTypes_ `[string[]]`: - Array of allowed media types. Default `['image']`.
- _props.allowedTypes_ `[string[]]`: - Array of allowed media types. Use `['*']` to allow all file types. Default `['image']`.
- _props.multiple_ `[boolean]`: - Whether to allow multiple media selections. Default `false`.
- _props.hideLabelFromVision_ `[boolean]`: - Whether the label should be hidden from vision.
- _props.isExpanded_ `[boolean]`: - Whether to render in an expanded form. Default `false`.
Expand Down
2 changes: 1 addition & 1 deletion packages/fields/src/components/media-edit/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ function CompactMediaEditAttachments( {
* @param {Item} props.data - The item being edited.
* @param {Object} props.field - The field configuration with getValue and setValue methods.
* @param {Function} props.onChange - Callback function when the media selection changes.
* @param {string[]} [props.allowedTypes] - Array of allowed media types. Default `['image']`.
* @param {string[]} [props.allowedTypes] - Array of allowed media types. Use `['*']` to allow all file types. Default `['image']`.
* @param {boolean} [props.multiple] - Whether to allow multiple media selections. Default `false`.
* @param {boolean} [props.hideLabelFromVision] - Whether the label should be hidden from vision.
* @param {boolean} [props.isExpanded] - Whether to render in an expanded form. Default `false`.
Expand Down
1 change: 1 addition & 0 deletions packages/fields/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ export interface MediaEditProps< Item >
> {
/**
* Array of allowed media types (e.g., ['image', 'video']).
* Use ['*'] to allow all file types.
*
* @default ['image']
*/
Expand Down
12 changes: 12 additions & 0 deletions packages/media-utils/src/utils/test/validate-mime-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,16 @@ describe( 'validateMimeType', () => {
} )
);
} );

it( 'should not error if allowedTypes contains the wildcard "*"', () => {
expect( () => {
validateMimeType( xmlFile, [ '*' ] );
} ).not.toThrow();
} );

it( 'should not error if allowedTypes contains "*" alongside other types', () => {
expect( () => {
validateMimeType( xmlFile, [ 'image', '*' ] );
} ).not.toThrow();
} );
} );
2 changes: 1 addition & 1 deletion packages/media-utils/src/utils/validate-mime-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { UploadError } from './upload-error';
* @param allowedTypes List of allowed mime types.
*/
export function validateMimeType( file: File, allowedTypes?: string[] ) {
if ( ! allowedTypes ) {
if ( ! allowedTypes || allowedTypes.includes( '*' ) ) {
return;
}

Expand Down
Loading