Fix uploaded media relative links when site has been moved, props DD32, fixes #8705 for trunk

git-svn-id: https://develop.svn.wordpress.org/trunk@10254 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Ozz 2008-12-26 02:59:04 +00:00
parent ede4a22a55
commit 7a9c742af6
1 changed files with 5 additions and 1 deletions

View File

@ -741,7 +741,7 @@ function get_post_custom_keys( $post_id = 0 ) {
function get_post_custom_values( $key = '', $post_id = 0 ) {
$custom = get_post_custom($post_id);
return $custom[$key];
return isset($custom[$key]) ? $custom[$key] : null;
}
/**
@ -2589,6 +2589,10 @@ function wp_get_attachment_url( $post_id = 0 ) {
if ( ($uploads = wp_upload_dir()) && false === $uploads['error'] ) { //Get upload directory
if ( 0 === strpos($file, $uploads['basedir']) ) //Check that the upload base exists in the file location
$url = str_replace($uploads['basedir'], $uploads['baseurl'], $file); //replace file location with url location
elseif ( false !== strpos($file, 'wp-content/uploads') )
$url = $uploads['baseurl'] . substr( $file, strpos($file, 'wp-content/uploads') + 18 );
else
$url = $uploads['baseurl'] . "/$file"; //Its a newly uploaded file, therefor $file is relative to the basedir.
}
}