Make WordPress Core

Ticket #39108: 39108.diff

File 39108.diff, 2.0 KB (added by etaproducto, 3 years ago)
  • src/wp-admin/includes/admin-filters.php

    diff --git src/wp-admin/includes/admin-filters.php src/wp-admin/includes/admin-filters.php
    index d03881c8ac..078eca0093 100644
    add_filter( 'async_upload_audio', 'get_media_item', 10, 2 ); 
    3131add_filter( 'async_upload_video', 'get_media_item', 10, 2 );
    3232add_filter( 'async_upload_file', 'get_media_item', 10, 2 );
    3333
    34 add_filter( 'attachment_fields_to_save', 'image_attachment_fields_to_save', 10, 2 );
    35 
    3634add_filter( 'media_upload_gallery', 'media_upload_gallery' );
    3735add_filter( 'media_upload_library', 'media_upload_library' );
    3836
  • src/wp-admin/includes/media.php

    diff --git src/wp-admin/includes/media.php src/wp-admin/includes/media.php
    index b015836a8b..4880f0ba72 100644
    function media_post_single_attachment_fields_to_edit( $form_fields, $post ) { 
    13211321        return $form_fields;
    13221322}
    13231323
    1324 /**
    1325  * Filters input from media_upload_form_handler() and assigns a default
    1326  * post_title from the file name if none supplied.
    1327  *
    1328  * Illustrates the use of the {@see 'attachment_fields_to_save'} filter
    1329  * which can be used to add default values to any field before saving to DB.
    1330  *
    1331  * @since 2.5.0
    1332  *
    1333  * @param array $post       The WP_Post attachment object converted to an array.
    1334  * @param array $attachment An array of attachment metadata.
    1335  * @return array Filtered attachment post object.
    1336  */
    1337 function image_attachment_fields_to_save( $post, $attachment ) {
    1338         if ( 'image' === substr( $post['post_mime_type'], 0, 5 ) ) {
    1339                 if ( strlen( trim( $post['post_title'] ) ) == 0 ) {
    1340                         $attachment_url                           = ( isset( $post['attachment_url'] ) ) ? $post['attachment_url'] : $post['guid'];
    1341                         $post['post_title']                       = preg_replace( '/\.\w+$/', '', wp_basename( $attachment_url ) );
    1342                         $post['errors']['post_title']['errors'][] = __( 'Empty Title filled from filename.' );
    1343                 }
    1344         }
    1345 
    1346         return $post;
    1347 }
    1348 
    13491324/**
    13501325 * Retrieves the media element HTML to send to the editor.
    13511326 *