Make WordPress Core

Opened 6 years ago

Closed 6 years ago

Last modified 5 years ago

#12639 closed defect (bug) (fixed)

upload_url_path is always overwritten in function wp_upload_dir

Reported by: jimmcq Owned by:
Milestone: 3.0 Priority: high
Severity: major Version: 3.0
Component: Upload Keywords:
Focuses: Cc:


I need to have a custom upload_path and upload_url_path so that uploads are served from a separate dedicated server. The problem is that the file URL is always being overwritten by a URL that points to a subdirectory under my main wordpress install.

I tracked down the problem to the following code within the wp_upload_dir function of wp-includes/functions.php:

if ( defined('UPLOADS') && ( WP_CONTENT_DIR . '/uploads' != ABSPATH . $upload_path ) ) {
    $dir = ABSPATH . UPLOADS;
    $url = trailingslashit( $siteurl ) . UPLOADS;

Because I have an $upload_path defined this conditional is always trigged and the $url is overwitten when I want it to keep it as get_option( 'upload_url_path' )

Change History (3)

#2 @ryan
6 years ago

  • Resolution set to fixed
  • Status changed from new to closed

I think fixes for #12549 address most of this. For MU setups it is customary to make path customizations via the UPLOADS constant.

#3 @jimmcq
5 years ago

I'm not really following how I can define UPLOADS to be a path completely outside of the Wordpress install with $dir = ABSPATH . UPLOADS;

That puts it right back under the Wordpress install.

Also I don't see how to have the upload_url point to a different server with $url = trailingslashit( $siteurl ) . UPLOADS;

What am I missing here and how can the UPLOADS constant help me around that?

Note: See TracTickets for help on using tickets.