mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-11 12:20:22 +00:00
Media: Account for Windows when normalizing file paths.
Previously, Windows paths in the `path_is_absolute` function resulted in incorrect URIs. This patch adjusts for forward slashes and adds tests for the `get_attached_file` function. Props Whissi, SergeyBiryukov, desrosj, stevenlinx, birgire, davidbaumwald, costdev, peterwilsoncc, audrasjb, hellofromTonya, johnbillion. Fixes #36308. git-svn-id: https://develop.svn.wordpress.org/trunk@53934 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -724,10 +724,11 @@ function get_attached_file( $attachment_id, $unfiltered = false ) {
|
||||
$file = get_post_meta( $attachment_id, '_wp_attached_file', true );
|
||||
|
||||
// If the file is relative, prepend upload dir.
|
||||
if ( $file && 0 !== strpos( $file, '/' ) && ! preg_match( '|^.:\\\|', $file ) ) {
|
||||
if ( $file ) {
|
||||
$uploads = wp_get_upload_dir();
|
||||
|
||||
if ( false === $uploads['error'] ) {
|
||||
$file = $uploads['basedir'] . "/$file";
|
||||
$file = path_join( $uploads['basedir'], $file );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user