Changeset 36120 for trunk/src/wp-includes/media.php
- Timestamp:
- 12/30/2015 12:05:07 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/media.php
r36110 r36120 879 879 880 880 /** 881 * Get the attachment path relative to the upload directory. 882 * 883 * @since 4.4.1 884 * @access private 885 * 886 * @param string $file Attachment file name. 887 * @return string Attachment path relative to the upload directory. 888 */ 889 function _wp_get_attachment_relative_path( $file ) { 890 $dirname = dirname( $file ); 891 892 if ( '.' === $dirname ) { 893 return ''; 894 } 895 896 if ( false !== strpos( $dirname, 'wp-content/uploads' ) ) { 897 // Get the directory name relative to the upload directory (back compat for pre-2.7 uploads) 898 $dirname = substr( $dirname, strpos( $dirname, 'wp-content/uploads' ) + 18 ); 899 $dirname = ltrim( $dirname, '/' ); 900 } 901 902 return $dirname; 903 } 904 905 /** 881 906 * Caches and returns the base URL of the uploads directory. 882 907 * … … 1007 1032 // Uploads are (or have been) in year/month sub-directories. 1008 1033 if ( $image_basename !== $image_meta['file'] ) { 1009 $dirname = dirname( $image_meta['file'] );1010 1011 if ( $dirname !== '.') {1034 $dirname = _wp_get_attachment_relative_path( $image_meta['file'] ); 1035 1036 if ( $dirname ) { 1012 1037 $image_baseurl = trailingslashit( $image_baseurl ) . $dirname; 1013 1038 } … … 1290 1315 $image_base_url = $base_url; 1291 1316 1292 $dirname = dirname( $image_meta['file'] );1293 if ( $dirname !== '.') {1317 $dirname = _wp_get_attachment_relative_path( $image_meta['file'] ); 1318 if ( $dirname ) { 1294 1319 $image_base_url .= trailingslashit( $dirname ); 1295 1320 } … … 1302 1327 1303 1328 // Add the original image. 1304 $all_sizes[] = $ base_url . $image_meta['file'];1329 $all_sizes[] = $image_base_url . basename( $image_meta['file'] ); 1305 1330 1306 1331 // Bail early if the image src doesn't match any of the known image sizes.
Note: See TracChangeset
for help on using the changeset viewer.