{$action}_prefilter
Filter HookDescription
Filters the data for a file before it is uploaded to WordPress. 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` }Hook Information
File Location |
wp-admin/includes/file.php
View on GitHub
|
Hook Type | Filter |
Line Number | 833 |
Hook Parameters
Type | Name | Description |
---|---|---|
array
|
$file
|
{ Reference to a single element from `$_FILES`. |
Usage Examples
Basic Usage
<?php
// Hook into {$action}_prefilter
add_filter('{$action}_prefilter', 'my_custom_filter', 10, 1);
function my_custom_filter($file) {
// Your custom filtering logic here
return $file;
}
Source Code Context
wp-admin/includes/file.php:833
- How this hook is used in WordPress core
<?php
828 * @type string $tmp_name The temporary filename of the file in which the uploaded file was stored on the server.
829 * @type int $size The size, in bytes, of the uploaded file.
830 * @type int $error The error code associated with this file upload.
831 * }
832 */
833 $file = apply_filters( "{$action}_prefilter", $file );
834
835 /**
836 * Filters the override parameters for a file before it is uploaded to WordPress.
837 *
838 * The dynamic portion of the hook name, `$action`, refers to the post action.
PHP Documentation
<?php
/**
* Filters the data for a file before it is uploaded to WordPress.
*
* 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`
*
* @since 2.9.0 as 'wp_handle_upload_prefilter'.
* @since 4.0.0 Converted to a dynamic hook with `$action`.
*
* @param array $file {
* 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.
* }
*/
Quick Info
- Hook Type: Filter
- Parameters: 1
- File: wp-admin/includes/file.php
Related Hooks
Related hooks will be displayed here in future updates.