Skip to content

Commit

Permalink
Editor: limit uploads to supported mime types
Browse files Browse the repository at this point in the history
  • Loading branch information
adamsilverstein committed Oct 23, 2024
1 parent 771ef17 commit b6cd9f1
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/wp-includes/block-editor.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,10 +211,19 @@ function get_default_block_editor_settings() {
);
}

$allowed_mime_types = get_allowed_mime_types();

// Iterate through mime types and check if they are supported by the image editor.
foreach ( $allowed_mime_types as $mime_type_extensions => $mime_type ) {
if ( ! wp_image_editor_supports( array( 'mime_type' => $mime_type ) ) ) {
unset( $allowed_mime_types[ $mime_type_extensions ] );
}
}

$editor_settings = array(
'alignWide' => get_theme_support( 'align-wide' ),
'allowedBlockTypes' => true,
'allowedMimeTypes' => get_allowed_mime_types(),
'allowedMimeTypes' => $allowed_mime_types,
'defaultEditorStyles' => $default_editor_styles,
'blockCategories' => get_default_block_categories(),
'isRTL' => is_rtl(),
Expand Down

0 comments on commit b6cd9f1

Please sign in to comment.