mirror of
https://github.com/WordPress/WordPress.git
synced 2024-10-03 10:07:53 +02:00
Fix uploaded media relative links when site has been moved, props DD32, fixes #8705 for 2.7
git-svn-id: http://svn.automattic.com/wordpress/branches/2.7@10253 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
4d9850ced6
commit
293e84f6cd
@ -741,7 +741,7 @@ function get_post_custom_keys( $post_id = 0 ) {
|
|||||||
function get_post_custom_values( $key = '', $post_id = 0 ) {
|
function get_post_custom_values( $key = '', $post_id = 0 ) {
|
||||||
$custom = get_post_custom($post_id);
|
$custom = get_post_custom($post_id);
|
||||||
|
|
||||||
return $custom[$key];
|
return isset($custom[$key]) ? $custom[$key] : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -2540,6 +2540,10 @@ function wp_get_attachment_url( $post_id = 0 ) {
|
|||||||
if ( ($uploads = wp_upload_dir()) && false === $uploads['error'] ) { //Get upload directory
|
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
|
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
|
$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.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user