mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-12 04:40:26 +00:00
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. git-svn-id: https://develop.svn.wordpress.org/trunk@38614 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -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 = '';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user