Filter hook 'upload_dir'

in WP Core File wp-includes/functions.php at line 2393

View Source

upload_dir

Filter Hook
Description
Filters the uploads directory data. }

Hook Information

File Location wp-includes/functions.php View on GitHub
Hook Type Filter
Line Number 2393

Hook Parameters

Type Name Description
array $uploads { Array of information about the upload directory.

Usage Examples

Basic Usage
<?php
// Hook into upload_dir
add_filter('upload_dir', 'my_custom_filter', 10, 1);

function my_custom_filter($uploads) {
    // Your custom filtering logic here
    return $uploads;
}

Source Code Context

wp-includes/functions.php:2393 - How this hook is used in WordPress core
<?php
2388  	 *     @type string       $basedir Path without subdir.
2389  	 *     @type string       $baseurl URL path without subdir.
2390  	 *     @type string|false $error   False or error message.
2391  	 * }
2392  	 */
2393  	$uploads = apply_filters( 'upload_dir', $cache[ $key ] );
2394  
2395  	if ( $create_dir ) {
2396  		$path = $uploads['path'];
2397  
2398  		if ( array_key_exists( $path, $tested_paths ) ) {

PHP Documentation

<?php
/**
	 * Filters the uploads directory data.
	 *
	 * @since 2.0.0
	 *
	 * @param array $uploads {
	 *     Array of information about the upload directory.
	 *
	 *     @type string       $path    Base directory and subdirectory or full path to upload directory.
	 *     @type string       $url     Base URL and subdirectory or absolute URL to upload directory.
	 *     @type string       $subdir  Subdirectory if uploads use year/month folders option is on.
	 *     @type string       $basedir Path without subdir.
	 *     @type string       $baseurl URL path without subdir.
	 *     @type string|false $error   False or error message.
	 * }
	 */
Quick Info
  • Hook Type: Filter
  • Parameters: 1
  • File: wp-includes/functions.php
Related Hooks

Related hooks will be displayed here in future updates.