From 55ee349c2e148ba83542ec993086114a0c80e3ac Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Wed, 16 Jul 2008 16:49:22 +0000 Subject: [PATCH] Derive the upload url from the upload path if no url given. fixes #7308 for trunk git-svn-id: https://develop.svn.wordpress.org/trunk@8352 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/functions.php | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/wp-includes/functions.php b/wp-includes/functions.php index fcb22f487e..355e7d771f 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -1481,15 +1481,21 @@ function path_join( $base, $path ) { function wp_upload_dir( $time = NULL ) { $siteurl = get_option( 'siteurl' ); $upload_path = get_option( 'upload_path' ); - if ( trim($upload_path) === '' ) - $upload_path = WP_CONTENT_DIR . '/uploads'; - $dir = $upload_path; + $upload_path = trim($upload_path); + if ( empty($upload_path) ) + $dir = WP_CONTENT_DIR . '/uploads'; + else + $dir = $upload_path; // $dir is absolute, $path is (maybe) relative to ABSPATH - $dir = path_join( ABSPATH, $upload_path ); + $dir = path_join( ABSPATH, $dir ); - if ( !$url = get_option( 'upload_url_path' ) ) - $url = WP_CONTENT_URL . '/uploads'; + if ( !$url = get_option( 'upload_url_path' ) ) { + if ( empty($upload_path) ) + $url = WP_CONTENT_URL . '/uploads'; + else + $url = trailingslashit( $siteurl ) . $upload_path; + } if ( defined('UPLOADS') ) { $dir = ABSPATH . UPLOADS;