Code Review
-
Hi
Will your plugin work smoothly after changing upload path using code below
/* Change wordpress media upload directory to (media) folder */
function custom_upload_directory( $upload ) {
// Set the custom directory name
$custom_directory = '/media';
// Always include year and month-based subfolders
$time = current_time( 'mysql' );
$y = substr( $time, 0, 4 );
$m = substr( $time, 5, 2 );
// Update path and URL to the custom directory with year and month
$upload['subdir'] = "$custom_directory/$y/$m";
$upload['path'] = $upload['basedir'] . $upload['subdir'];
$upload['url'] = $upload['baseurl'] . $upload['subdir'];
return $upload;
}
add_filter( 'upload_dir', 'custom_upload_directory' );Note that the media settings option (Organize my uploads into month- and year-based folders) is disabled to avoid conflict with code above
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
You must be logged in to reply to this topic.