Permalink
Browse files

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.


Built from https://develop.svn.wordpress.org/trunk@38614


git-svn-id: http://core.svn.wordpress.org/trunk@38557 1a063a9b-81f0-0310-95a4-ce76da25c4cd
  • Loading branch information...
1 parent 15df6d2 commit 405def3da40f9090361d9be9ad94b51a8fbe3f2d @aaroncampbell aaroncampbell committed Sep 17, 2016
Showing with 3 additions and 4 deletions.
  1. +2 −3 wp-admin/includes/media.php
  2. +1 −1 wp-includes/version.php
@@ -278,18 +278,17 @@ function media_handle_upload($file_id, $post_id, $post_data = array(), $override
$time = $post->post_date;
}
- $name = $_FILES[$file_id]['name'];
$file = wp_handle_upload($_FILES[$file_id], $overrides, $time);
if ( isset($file['error']) )
return new WP_Error( 'upload_error', $file['error'] );
- $basename = pathinfo( $name, PATHINFO_BASENAME );
+ $name = pathinfo( $_FILES[$file_id]['name'], PATHINFO_FILENAME );
$url = $file['url'];
$type = $file['type'];
$file = $file['file'];
- $title = sanitize_title( $basename );
+ $title = sanitize_text_field( $name );
$content = '';
$excerpt = '';
@@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
-$wp_version = '4.7-alpha-38613';
+$wp_version = '4.7-alpha-38614';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.

0 comments on commit 405def3

Please sign in to comment.