WordPress.org

Make WordPress Core

Opened 5 years ago

Last modified 5 months ago

#30687 new enhancement

Ajax media attachment save has no error handling

Reported by: Krielkip Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.0.1
Component: Media Keywords: needs-patch
Focuses: ui Cc:
PR Number:

Description

When using the ajax media system on adding media in posts. It is not possible to show errors to the users.

In the file ajax-actions.php (located wp-admin/includes/) in the function wp_ajax_save_attachment_compat() the feedback of errors is trown away. If this code is further developed with visual feedback, the user understand why data is not saved or imported.

Code: (wp 4.0.1 line 2294)

if ( isset( $post['errors'] ) ) {
		$errors = $post['errors']; // @todo return me and display me!
		unset( $post['errors'] );
	}

Change History (4)

#1 @SergeyBiryukov
5 years ago

  • Summary changed from Ajax media attachment save has no error handeling to Ajax media attachment save has no error handling
  • Type changed from feature request to enhancement

#2 @wonderboymusic
5 years ago

  • Keywords needs-patch added
  • Milestone changed from Awaiting Review to Future Release

#3 @locomo
4 years ago

Not sure if this changes how this ticket would get prioritized, but shouldn't this be marked as a bug (rather than enhancement)? The current code actually silently unsets $post['errors'] passed into it and processes without any notice to the user.

This took me forever to track down. I updated documentation for the filter 'attachment_fields_to_save' to warn developers that we can't currently validate custom attachment fields with this filter

Last edited 4 years ago by locomo (previous) (diff)

#4 in reply to: ↑ description @Krielkip
3 years ago

Can't we use the following function to give some feedback to the user?

wp_send_json_error( $data );

Then Data has the error information and shown good to the user?

Note: See TracTickets for help on using tickets.