WordPress filter hook · part of WordPress core
wp_handle_upload
A WordPress core filter that 42 plugins also fire themselves, running on 2.2M+ sites between them.
“Filter the data array for the uploaded file.”
How to use wp_handle_upload
It's a filter: your callback receives the value and 1 more argument, and must return the (changed) value.
Add this to your theme's functions.php or a small custom plugin:
add_filter( 'wp_handle_upload', function( $value, $arg2 ) {
// Change $value here.
return $value;
}, 10, 2 );Argument names come from Seraphinite Accelerator's source. Other plugins may pass different values: check the call in the plugin you're targeting below.
This hook is fired by WordPress core too. Official reference on developer.wordpress.org →
42 plugins that fire wp_handle_upload
Sorted by active installs. Each entry shows where the plugin calls the hook and what it passes.
-
WPvivid900,000+ installs
apply_filters( 'wp_handle_upload', array( 'file' => $new_file, 'url' => $url, 'type' => $wp_filetype['type'], 'error' => false, ), 'sideload' )includes/class-wpvivid-importer.php:1733 -
Enable Media Replace600,000+ installs
apply_filters( 'wp_handle_upload', array( 'file' => $this->targetFile->getFullPath(), 'url' => $this->getTargetURL(), 'type' => $this->targetFile->getMime(), ), 'sideload' )classes/Controller/ReplaceController.php:159 -
Page Builder: Pagelayer400,000+ installs
apply_filters( 'wp_handle_upload', array( 'file' => $targetFile, 'url' => $target_url, 'type' => $fileMime, ), 'sideload' )main/replace-media.php:184 -
Modula Image Gallery100,000+ installs
apply_filters( 'wp_handle_upload', array( 'file' => $destination_file_path, 'url' => $destination_url, 'type' => $type, ) )includes/features/migrate/class-modula-ajax-migrator.php:173 -
Add From Server50,000+ installs
apply_filters( 'wp_handle_upload', array( 'file' => $new_file, 'url' => $url, 'type' => $type ) )class.add-from-server.php:224 -
Seraphinite Accelerator50,000+ installs
apply_filters( 'wp_handle_upload', array( 'file' => $file[ 'name' ], 'url' => $post_img_dir . '/' . $file[ 'name' ], 'type' => $file[ 'type' ] ), 'upload' )Cmn/Gen.php:6135 -
Backup and Staging by WP Time Capsule10,000+ installs
apply_filters( 'wp_handle_upload', array( 'file' => $new_file, 'url' => $url, 'type' => $type, ), 'wp_handle_sideload' === $action ? 'sideload' : 'upload' )wp-tcapsule-bridge/wp-files/file.php:405 -
FV Flowplayer Video Player10,000+ installs
apply_filters( 'wp_handle_upload', array( 'file' => $upload['file'], 'url' => $upload['url'], 'type' => $wp_filetype['type'] ), 'sideload' )controller/editor.php:410 -
User Submitted Posts10,000+ installs
apply_filters( 'wp_handle_upload', array('file' => $file, 'url' => $guid, 'type' => $file_type) )user-submitted-posts.php:1243 -
BlockSpare10,000+ installs
apply_filters( 'wp_handle_upload', array('file' => $file_path, 'url' => $file_url, 'type' => $file_type), 'upload' )inc/layout/class-image-importer.php:116 -
Microthemer10,000+ installs
apply_filters( 'wp_handle_upload', array( 'file' => $new_file, 'url' => $url, 'type' => $type ) )src/PackTrait.php:1024 -
HTML Import 25,000+ installs
apply_filters( 'wp_handle_upload', array( 'file' => $new_file, 'url' => $url, 'type' => wp_check_filetype( $file, null ) ) )html-importer.php:742 -
Avatar Manager5,000+ installs
apply_filters( 'wp_handle_upload', $struct, 'upload' )avatar-manager.php:1488 -
Add From Server Lite4,000+ installs
apply_filters( 'wp_handle_upload', array( 'file' => $new_file, 'url' => $url, 'type' => $type, ), 'sideload' )class.add-from-server.php:1473 -
teachPress2,000+ installs
apply_filters( 'wp_handle_upload', array( 'file' => $new_file, 'url' => $url, 'path' => "/teachpress$extra_directory_part/$filename", 'type' => $type, 'size' => $file['size'], 'filename' => $filename ), 'upload' )core/admin.php:791 -
Microsoft Azure Storage for WordPress2,000+ installs
apply_filters( 'wp_handle_upload', $struct, 'upload' )windows-azure-storage.php:394 -
Video Thumbnails Reloaded2,000+ installs
apply_filters( 'wp_handle_upload', array( 'file' => $upload['file'], 'url' => $upload['url'], 'type' => $wp_filetype['type'] ), 'sideload' )video-thumbnails.php:428 -
FV Player 81,000+ installs
apply_filters( 'wp_handle_upload', array( 'file' => $upload['file'], 'url' => $upload['url'], 'type' => $wp_filetype['type'] ), 'sideload' )controller/editor.php:440 -
Seraphinite Post .DOCX Source800+ installs
apply_filters( 'wp_handle_upload', array( 'file' => $file[ 'name' ], 'url' => $post_img_dir . '/' . $file[ 'name' ], 'type' => $file[ 'type' ] ), 'upload' )Cmn/Gen.php:5955 -
Skyword Publishing API500+ installs
apply_filters( 'wp_handle_upload', array( 'file' => $fields['fileName']['value'], 'url' => $upload['url'], ), 'upload' )php/routes/class-skyword-authors.php:210 -
WP Easy Uploader500+ installs
apply_filters( 'wp_handle_upload', array( 'file' => $uploads['path'] . '/' . $filename, 'url' => $url, 'message' => $message, 'error' => false ) )wp-easy-uploader.php:781 -
MediaBlaster200+ installs
apply_filters( 'wp_handle_upload', array( 'file' => $upload['file'], 'url' => $upload['url'], 'type' => $wp_filetype['type'], ), 'sideload' )includes/controls/class-wp-smart-tv-import-ajax.php:313 -
WooTumblog80+ installs
apply_filters( 'wp_handle_upload', array( 'file' => $name, 'url' => $upload[ 'url' ], 'type' => $type , 'id' => $id ) )functions/wootumblog_express_app_functions_deprecated.php:255 -
Posterous Importer80+ installs
apply_filters( 'wp_handle_upload', $upload )posterous.php:544 -
XML-RPC Modernization80+ installs
apply_filters( 'wp_handle_upload', $struct, 'upload' )class-wp-xmlrpc-server-ext.php:2278 -
Skyword XMLRPC publishing40+ installs
apply_filters( 'wp_handle_upload', array( 'file' => $name, 'url' => $upload['url'], 'type' => $type ), 'upload' )php/class-skyword-publish.php:600 -
ExXmlRpc for WordPressPost30+ installs
apply_filters( 'wp_handle_upload', array( 'file' => $name, 'url' => $upload[ 'url' ], 'type' => $type, 'id' => $id ), 'upload' )exXmlRpc.php:297 -
photostream-sync30+ installs
apply_filters( 'wp_handle_upload', $struct, 'upload' )photostream-sync.php:1535 -
WP Developer Assistant30+ installs
apply_filters( 'wp_handle_upload', array( 'file' => $uploads['path'] . '/' . $filename, 'url' => $url, 'message' => $message, 'error' => false ) )wp-developer-assistant.php:1719 -
Seraphinite Bulk Discounts for WooCommerce20+ installs
apply_filters( 'wp_handle_upload', array( 'file' => $file[ 'name' ], 'url' => $post_img_dir . '/' . $file[ 'name' ], 'type' => $file[ 'type' ] ), 'upload' )Cmn/Gen.php:5351 -
Blue Storage10+ installs
apply_filters( 'wp_handle_upload', $struct, 'upload' )blue-storage.php:320 -
Seraphinite Downloads Statistics10+ installs
apply_filters( 'wp_handle_upload', array( 'file' => $file[ 'name' ], 'url' => $post_img_dir . '/' . $file[ 'name' ], 'type' => $file[ 'type' ] ), 'upload' )Cmn/Gen.php:5790 -
Seraphinite Alternative Slugs Manager10+ installs
apply_filters( 'wp_handle_upload', array( 'file' => $file[ 'name' ], 'url' => $post_img_dir . '/' . $file[ 'name' ], 'type' => $file[ 'type' ] ), 'upload' )Cmn/Gen.php:5043 -
Crypto Coin Market Prices10+ installs
apply_filters( 'wp_handle_upload', array( 'file' => $file[ 'name' ], 'url' => $post_img_dir . '/' . $file[ 'name' ], 'type' => $file[ 'type' ] ), 'upload' )Cmn/Gen.php:1627 -
bbPress Post via Mail10+ installs
apply_filters( 'wp_handle_upload', array('file' => $new_file, 'url' => $url,'type' => $attachment->ContentType) )library/pvm/Reply.php:167 -
PressRoom by Newswire10+ installs
apply_filters( 'wp_handle_upload', array('file' => $new_file, 'url' => $url, 'type' => $type) )includes/activate.php:214 -
YouTube Post Type10+ installs
apply_filters( 'wp_handle_upload', array( 'file' => $new_file, 'url' => $url, 'type' => $type ) )youtube_post_type.php:164 -
Webangon Image OptimizerFewer than 10 installs
apply_filters( 'wp_handle_upload', array( 'file' => $target_path, 'url' => $this->path_to_url( $target_path ), 'type' => $upload['type'], ), 'sideload' )includes/class-webangon-media-replace.php:492 -
Testimonials WPFewer than 10 installs
apply_filters( 'wp_handle_upload', array('file' => $file_path, 'url' => $file_url, 'type' => $file_type), 'upload' )php_libraries/twp_image_class.php:42 -
Share ClusterFewer than 10 installs
apply_filters( 'wp_handle_upload', array( 'file' => $new_file, 'url' => $url, 'type' => $type ), 'upload' )cluster-includes/functions.php:1297 -
LoveIt.com ImporterFewer than 10 installs
apply_filters( 'wp_handle_upload', $upload )loveit-importer-class.php:931 -
Exhibit to WP GalleryFewer than 10 installs
apply_filters( 'wp_handle_upload', array( 'file' => $new_file, 'url' => $url, 'type' => $type ) )exhibit-to-wp-gallery.php:336
Need a customisation built on this hook?
Tell us what you want to change and which plugin it's for. We'll write it, test it and send it back as a small plugin.