WordPress.org

Make WordPress Core


Ignore:
Timestamp:
09/17/2016 05:41:27 AM (3 years ago)
Author:
aaroncampbell
Message:

Media: Improved media titles when created from filename.

Preserves spaces and generally creates more accurate, cleaner titles from filenames of uploaded media.

Props joemcgill.
Fixes #37989.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/media.php

    r38538 r38614  
    279279    }
    280280
    281     $name = $_FILES[$file_id]['name'];
    282281    $file = wp_handle_upload($_FILES[$file_id], $overrides, $time);
    283282
     
    285284        return new WP_Error( 'upload_error', $file['error'] );
    286285
    287     $basename = pathinfo( $name, PATHINFO_BASENAME );
     286    $name = pathinfo( $_FILES[$file_id]['name'], PATHINFO_FILENAME );
    288287
    289288    $url = $file['url'];
    290289    $type = $file['type'];
    291290    $file = $file['file'];
    292     $title = sanitize_title( $basename );
     291    $title = sanitize_text_field( $name );
    293292    $content = '';
    294293    $excerpt = '';
Note: See TracChangeset for help on using the changeset viewer.