Make WordPress Core

Opened 13 years ago

Closed 13 years ago

Last modified 13 years ago

#23063 closed enhancement (wontfix)

Add 'UPLOADS_URL' constant to work in tandem with the 'UPLOADS' constant

Reported by: wesrice's profile wesrice Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.5
Component: Upload Keywords:
Focuses: Cc:

Description

I've looked at core and see that the uploads url is now based on WP_CONTENT_URL. Thus, all images urls are prepended with WP_CONTENT_URL, which is fine unless the developer has decided put their images above their WordPress installation.

Personally, I have my WordPress install in a subdirectory and define 'UPLOADS' as '../uploads' to get my uploads folder as the same level as my WordPress install. I do this not only for organizational purposes, but also for the safety of my website, particularly if a client decides they need to utilize their FTP. I don't want them mucking up WordPress. I also like putting WP in subdirectory for obscurity from the outside world.

I've read an argument against defining UPLOADS_URL in the config as a constant because it would likely confuse new users. I hardly think that is true, because most new users won't even need to define UPLOADS in their wp-config.php file.

For now it looks like users have to manually set the 'upload_url_path' option in their function.php file to override this, which is hardly ideal, especially when working with multiple environments for dev, staging and production.

I am under no impression that I am fringe case, and I think UPLOADS_URL should be considered regardless of my situation. If a USER could make this decision (as they have for years in the Dashboard Settings), then a DEVELOPER should be able to make this decision themselves now.

Change History (4)

#1 @markoheijnen
13 years ago

  • Keywords close added
  • Severity changed from critical to trivial

I think it is better to use the filter 'upload_dir' for this case. So I guess this ticket can be closed since there is a (better) way of dealing with this.

#2 @ocean90
13 years ago

  • Keywords 2nd-opinion ux-feedback close removed
  • Milestone Awaiting Review deleted
  • Resolution set to wontfix
  • Severity changed from trivial to normal
  • Status changed from new to closed
  • Type changed from feature request to enhancement

Related: [21852]

For the upload_dir filter take a look into wp_upload_dir().

#3 @kadamwhite
13 years ago

I may be missing something, but from the code I still feel there's room to improve how wp_upload_dir() works to handle what is asked here—If I have my WordPress install in server_root/wp/, but I want images to be uploaded to server_root/files/, I have to actually manipulate the raw ABSPATH value in order for wp_upload_dir() to correctly parse my needs:

if ( empty( $upload_path ) || 'wp-content/uploads' == $upload_path ) {
	update_option( 'upload_path', untrailingslashit( str_replace( 'backend', 'files', ABSPATH ) ) );
	update_option( 'upload_url_path', home_url( '/files' ) );
}

Is this easy to do? Sure—but I feel that there's room to allow for a case where your media should be relative to the server root, not ABSPATH or WP_CONTENT_URL.

#4 @kadamwhite
13 years ago

  • Cc kadamwhite added
Note: See TracTickets for help on using tickets.