From f555d94c3f5598250645ad39275ff17360bf69d2 Mon Sep 17 00:00:00 2001 From: ryan 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: http://svn.automattic.com/wordpress/trunk@8352 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- 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;