Changes between Initial Version and Version 1 of Ticket #37989, comment 11
- Timestamp:
- 09/27/2016 03:17:32 AM (9 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #37989, comment 11
initial v1 1 1 A workaround: 2 2 {{{ 3 function wp37989_fix_encoded_attachment_titles( $data, $postarr ) { 4 $basename = pathinfo( $postarr['file'], PATHINFO_BASENAME ); 3 function wp37989_fix_encoded_attachment_titles( $data ) { 4 if ( empty( $_FILES ) ) { 5 return $data; 6 } 5 7 6 $data['post_title'] = sanitize_text_field( $basename ); 8 $file = current( $_FILES ); 9 $ext = pathinfo( $file['name'], PATHINFO_EXTENSION ); 10 $name = wp_basename( $file['name'], ".$ext" ); 11 12 $data['post_title'] = sanitize_text_field( $name ); 7 13 8 14 return $data; 9 15 } 10 add_filter( 'wp_insert_attachment_data', 'wp37989_fix_encoded_attachment_titles' , 10, 2);16 add_filter( 'wp_insert_attachment_data', 'wp37989_fix_encoded_attachment_titles' ); 11 17 }}}