wp_handle_upload filter-hookWP 2.1.0

Filters the data array for the uploaded file.

Usage

add_filter( 'wp_handle_upload', 'wp_kama_handle_upload_filter', 10, 2 );

/**
 * Function for `wp_handle_upload` filter-hook.
 * 
 * @param array  $upload  Array of upload data.
 * @param string $context The type of upload action. Values include 'upload' or 'sideload'.
 *
 * @return array
 */
function wp_kama_handle_upload_filter( $upload, $context ){

	// filter...
	return $upload;
}
$upload(array)

Array of upload data.

  • file(string)
    Filename of the newly-uploaded file.

  • url(string)
    URL of the newly-uploaded file.

  • type(string)
    Mime type of the newly-uploaded file.
$context(string)
The type of upload action. Values include 'upload' or 'sideload'.

Changelog

Since 2.1.0 Introduced.

Where the hook is called

_wp_handle_upload()
wp_handle_upload
wp_upload_bits()
wp_handle_upload
wp-admin/includes/file.php 1035-1043
return apply_filters(
	'wp_handle_upload',
	array(
		'file' => $new_file,
		'url'  => $url,
		'type' => $type,
	),
	'wp_handle_sideload' === $action ? 'sideload' : 'upload'
);
wp-includes/functions.php 2947-2956
return apply_filters(
	'wp_handle_upload',
	array(
		'file'  => $new_file,
		'url'   => $url,
		'type'  => $wp_filetype['type'],
		'error' => false,
	),
	'sideload'
);

Where the hook is used in WordPress

Usage not found.