wppaste
WordPress

apply_filters( "{$action}_prefilter", array $file )

Since
2.9.0, 4.0.0
Filters the data for a file before it is uploaded to WordPress.

Description

The dynamic portion of the hook name, $action, refers to the post action.

Possible hook names include:

  • wp_handle_sideload_prefilter
  • wp_handle_upload_prefilter

Compatibility

WordPress
since 4.0.0
  • 6.7.7
  • 6.8.8
  • 6.9.7
  • 7.0.4
  • 7.1.0

Present in every tracked release (6.7.7 to 7.1.0).

Parameters

$filearray
{ Reference to a single element from $_FILES.
@type string $name The original name of the file on the client machine.
@type string $type The mime type of the file, if the browser provided this information.
@type string $tmp_name The temporary filename of the file in which the uploaded file was stored on the server.
@type int $size The size, in bytes, of the uploaded file.
@type int $error The error code associated with this file upload.
}
  • $namestring

    The original name of the file on the client machine.
  • $typestring

    The mime type of the file, if the browser provided this information.
  • $tmp_namestring

    The temporary filename of the file in which the uploaded file was stored on the server.
  • $sizeint

    The size, in bytes, of the uploaded file.
  • $errorint

    The error code associated with this file upload.

Where this hook fires · 1

  • wp-admin/includes/file.php:840_wp_handle_upload()

Source code

	 *     @type string $type     The mime type of the file, if the browser provided this information.	 *     @type string $tmp_name The temporary filename of the file in which the uploaded file was stored on the server.	 *     @type int    $size     The size, in bytes, of the uploaded file.	 *     @type int    $error    The error code associated with this file upload.	 * }	 */	$file = apply_filters( "{$action}_prefilter", $file ); 	/**	 * Filters the override parameters for a file before it is uploaded to WordPress.	 *	 * The dynamic portion of the hook name, `$action`, refers to the post action.	 *

Changelog

Introduced in 4.0.0. Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

4.0.0
Converted to a dynamic hook with $action.from the docblock
2.9.0
as 'wp_handle_upload_prefilter'.from the docblock

About this page

Parsed data
Generated from the wordpress-develop 7.1.0 tag, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.