if ( empty( $attachment_id ) || !
current_user_can( 'edit_post',
$attachment_id ) ) { wp_die( -1
);
} check_ajax_referer( "image_editor-
$attachment_id"
);
require_once ABSPATH . 'wp-admin/includes/image-edit.php';
$msg = false;
switch ( $_POST['do'
] ) { case 'save':
$msg =
wp_save_image( $attachment_id );
if ( !
empty( $msg->error
) ) { wp_send_json_error( $msg );
} wp_send_json_success( $msg );
break;
case 'scale':
$msg =
wp_save_image( $attachment_id );
break;
case 'restore':
$msg =
wp_restore_image( $attachment_id );