Skip to main content

Filter: gk/block-mcp/media/upload-overrides

Fine-tune how WordPress handles an agent's multipart file upload.

Every file the agent uploads through POST /media is finally handed to core's wp_handle_upload(), and this array is the control panel for that step. Hook in when you need to bend the rules for a specific deployment — relax a check, accept an extra MIME type, or route the file through a different upload action. The value is forwarded verbatim as the overrides argument to media_handle_upload(). Most sites should leave the default array( 'test_form' => false ) alone; if a filter returns anything that isn't an array, the plugin safely falls back to that default.

Parameters

NameTypeDescription
$default_overridesarrayOverrides passed to media_handle_upload(). Default array( 'test_form' => false ).
$fieldstringThe $_FILES key whose upload is being processed.

Example

// Permit an extra file type for agent uploads.

add_filter( 'gk/block-mcp/media/upload-overrides', function ( $overrides, $field ) {
$overrides['mimes'] = array( 'webp' => 'image/webp' );
return $overrides;
}, 10, 2 );

Since

Source

Defined in wordpress-plugin/gk-block-api/includes/class-media-manager.php at line 251