apply_filters( 'upload_dir', array $uploads )
Filters the uploads directory data.
Parameters
-
$uploads
array -
Array of information about the upload directory.
path
stringBase directory and subdirectory or full path to upload directory.url
stringBase URL and subdirectory or absolute URL to upload directory.subdir
stringSubdirectory if uploads use year/month folders option is on.basedir
stringPath without subdir.baseurl
stringURL path without subdir.error
string|falseFalse or error message.
More Information
This hook allows you to change the directory where files are uploaded to. The keys and values in the array are used by the wp_upload_dir() function in wordpress core, which is doing the work
Source
File: wp-includes/functions.php
.
View all references
$uploads = apply_filters( 'upload_dir', $cache[ $key ] );
Changelog
Version | Description |
---|---|
2.0.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.
This goes into your plugin.
If your plugin is written as a class, you’ll want to hook to it like this:
Using this, in conjunction with the
wp_handle_upload_prefilter
, you can dynamically determine which directory to upload to, based on the files you upload.