Filters the uploads directory data.
Parameters
$uploadsarray- Array of information about the upload directory.
pathstringBase directory and subdirectory or full path to upload directory.urlstringBase URL and subdirectory or absolute URL to upload directory.subdirstringSubdirectory if uploads use year/month folders option is on.basedirstringPath without subdir.baseurlstringURL path without subdir.errorstring|falseFalse or error message.
Source
$uploads = apply_filters( 'upload_dir', $cache[ $key ] );
Changelog
| Version | Description |
|---|---|
| 2.0.0 | Introduced. |
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.