Changeset 12163 for trunk/wp-includes/post.php
- Timestamp:
- 11/11/2009 11:24:01 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/post.php
r12158 r12163 69 69 70 70 $file = apply_filters( 'update_attached_file', $file, $attachment_id ); 71 72 // Make the file path relative to the upload dir 73 if ( ($uploads = wp_upload_dir()) && false === $uploads['error'] ) { // Get upload directory 74 if ( 0 === strpos($file, $uploads['basedir']) ) {// Check that the upload base exists in the file path 75 $file = str_replace($uploads['basedir'], '', $file); // Remove upload dir from the file path 76 $file = ltrim($file, '/'); 77 } 78 } 71 $file = _wp_relative_upload_path($file); 79 72 80 73 return update_post_meta( $attachment_id, '_wp_attached_file', $file ); 74 } 75 76 /** 77 * Return relative path to an uploaded file. 78 * 79 * The path is relative to the current upload dir. 80 * 81 * @since 2.9 82 * @uses apply_filters() Calls '_wp_relative_upload_path' on file path. 83 * 84 * @param string $path Full path to the file 85 * @return string relative path on success, unchanged path on failure. 86 */ 87 function _wp_relative_upload_path( $path ) { 88 $new_path = $path; 89 90 if ( ($uploads = wp_upload_dir()) && false === $uploads['error'] ) { 91 if ( 0 === strpos($new_path, $uploads['basedir']) ) { 92 $new_path = str_replace($uploads['basedir'], '', $new_path); 93 $new_path = ltrim($new_path, '/'); 94 } 95 } 96 97 return apply_filters( '_wp_relative_upload_path', $new_path, $path ); 81 98 } 82 99
Note: See TracChangeset
for help on using the changeset viewer.