WordPress.org

Make WordPress Core

Changeset 16154


Ignore:
Timestamp:
11/02/10 17:19:55 (3 years ago)
Author:
scribu
Message:

Introduce wp_basename() and use it for media handling. See #11887

Location:
trunk/wp-includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/formatting.php

    r16151 r16154  
    28452845 
    28462846/** 
     2847 * i18n friendly version of basename() 
     2848 * 
     2849 * @since 3.1.0 
     2850 * 
     2851 * @param string $path A path. 
     2852 * @param string $suffix If the filename ends in suffix this will also be cut off. 
     2853 * @return string 
     2854 */ 
     2855function wp_basename( $path, $suffix = '' ) { 
     2856    return urldecode( basename( str_replace( '%2F', '/', urlencode( $path ) ), $suffix ) ); 
     2857} 
     2858 
     2859/** 
    28472860 * Forever eliminate "Wordpress" from the planet (or at least the little bit we can influence). 
    28482861 * 
     
    28512864 * @since 3.0.0 
    28522865 */ 
    2853  
    28542866function capital_P_dangit( $text ) { 
    28552867    // Simple replacement for titles 
  • trunk/wp-includes/media.php

    r15990 r16154  
    138138    $width = $height = 0; 
    139139    $is_intermediate = false; 
     140    $img_url_basename = wp_basename($img_url); 
    140141 
    141142    // plugins can use this to provide resize services 
     
    145146    // try for a new style intermediate size 
    146147    if ( $intermediate = image_get_intermediate_size($id, $size) ) { 
    147         $img_url = str_replace(basename($img_url), $intermediate['file'], $img_url); 
     148        $img_url = str_replace($img_url_basename, $intermediate['file'], $img_url); 
    148149        $width = $intermediate['width']; 
    149150        $height = $intermediate['height']; 
     
    153154        // fall back to the old thumbnail 
    154155        if ( ($thumb_file = wp_get_attachment_thumb_file($id)) && $info = getimagesize($thumb_file) ) { 
    155             $img_url = str_replace(basename($img_url), basename($thumb_file), $img_url); 
     156            $img_url = str_replace($img_url_basename, wp_basename($thumb_file), $img_url); 
    156157            $width = $info[0]; 
    157158            $height = $info[1]; 
     
    437438    $dir = $info['dirname']; 
    438439    $ext = $info['extension']; 
    439     $name = basename($file, ".{$ext}"); 
     440    $name = wp_basename($file, ".$ext"); 
     441 
    440442    if ( !is_null($dest_path) and $_dest_path = realpath($dest_path) ) 
    441443        $dir = $_dest_path; 
     
    486488            $resized_file = apply_filters('image_make_intermediate_size', $resized_file); 
    487489            return array( 
    488                 'file' => basename( $resized_file ), 
     490                'file' => wp_basename( $resized_file ), 
    489491                'width' => $info[0], 
    490492                'height' => $info[1], 
     
    607609    if ( $icon && $src = wp_mime_type_icon($attachment_id) ) { 
    608610        $icon_dir = apply_filters( 'icon_dir', ABSPATH . WPINC . '/images/crystal' ); 
    609         $src_file = $icon_dir . '/' . basename($src); 
     611        $src_file = $icon_dir . '/' . wp_basename($src); 
    610612        @list($width, $height) = getimagesize($src_file); 
    611613    } 
Note: See TracChangeset for help on using the changeset viewer.