WordPress.org

Make WordPress Core

Ticket #25236: 25236.patch

File 25236.patch, 1.4 KB (added by SergeyBiryukov, 7 years ago)
  • src/wp-admin/includes/media.php

     
    914914 * @param array $attachment {@internal $attachment not used}}
    915915 * @return array
    916916 */
    917 function image_attachment_fields_to_save($post, $attachment) {
    918         if ( substr($post['post_mime_type'], 0, 5) == 'image' ) {
    919                 if ( strlen(trim($post['post_title'])) == 0 ) {
    920                         $post['post_title'] = preg_replace('/\.\w+$/', '', basename($post['guid']));
    921                         $post['errors']['post_title']['errors'][] = __('Empty Title filled from filename.');
     917function image_attachment_fields_to_save( $post, $attachment ) {
     918        if ( substr( $post['post_mime_type'], 0, 5 ) == 'image' ) {
     919                if ( strlen( trim( $post['post_title'] ) ) == 0 ) {
     920                        $attachment_url = ( isset( $post['attachment_url'] ) ) ? $post['attachment_url'] : $post['guid'];
     921                        $post['post_title'] = preg_replace( '/\.\w+$/', '', wp_basename( $attachment_url ) );
     922                        $post['errors']['post_title']['errors'][] = __( 'Empty Title filled from filename.' );
    922923                }
    923924        }
    924925
     
    925926        return $post;
    926927}
    927928
    928 add_filter('attachment_fields_to_save', 'image_attachment_fields_to_save', 10, 2);
     929add_filter( 'attachment_fields_to_save', 'image_attachment_fields_to_save', 10, 2 );
    929930
    930931/**
    931932 * {@internal Missing Short Description}}