upload_dir WordPress Filter Hook

The upload_dir hook is a filter hook that can be used to modify the default upload directory for a WordPress site. This can be useful for customizing where files are uploaded, or for changing the structure of the default upload directory.

apply_filters( 'upload_dir', array $uploads ) #

Filters the uploads directory data.


Parameters

$uploads

(array)Array of information about the upload directory.

  • 'path'
    (string) Base directory and subdirectory or full path to upload directory.
  • 'url'
    (string) Base URL and subdirectory or absolute URL to upload directory.
  • 'subdir'
    (string) Subdirectory if uploads use year/month folders option is on.
  • 'basedir'
    (string) Path without subdir.
  • 'baseurl'
    (string) URL path without subdir.
  • 'error'
    (string|false) False or error message.


Top ↑

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


Top ↑

Source

File: wp-includes/functions.php

View on Trac



Top ↑

Changelog

Changelog
VersionDescription
2.0.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by the Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More
Show More