[wp-trac] [WordPress Trac] #50089: Allow filtering of image uploads

WordPress Trac noreply at wordpress.org
Tue May 5 07:16:52 UTC 2020


#50089: Allow filtering of image uploads
-------------------------+-----------------------------
 Reporter:  malthert     |      Owner:  (none)
     Type:  enhancement  |     Status:  new
 Priority:  normal       |  Milestone:  Awaiting Review
Component:  Media        |    Version:  trunk
 Severity:  normal       |   Keywords:  has-patch
  Focuses:               |
-------------------------+-----------------------------
 I'd like to be able to filter the response of wp_ajax_upload_attachment to
 add copyright and duplicate checks to prevent the upload of the image if
 either fails.

 To do this I require an apply_filters at the end of the function.

 Suggested fix for ajax-actions.php function wp_ajax_upload_attachment:

 Replace:
 {{{#!php
 echo wp_json_encode( array(
         'success' => true,
         'data'    => $attachment,
 ) );
 }}}


 with:

 {{{#!php
 $response = array(
     'success' => true,
     'data'    => $attachment,
 );
 $response = apply_filters( 'filter_ajax_upload_attachment_response',
 $response );

 echo wp_json_encode( $response );
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/50089>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list