wp_ajax_image_editor

Ajax handler for image editing.

Description

wp_ajax_image_editor(); 

Usage

  1. if ( !function_exists( 'wp_ajax_image_editor' ) ) { 
  2. require_once ABSPATH . '/wp-admin/includes/ajax-actions.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = wp_ajax_image_editor(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/wp-admin/includes/ajax-actions.php  
  1. function wp_ajax_image_editor() { 
  2. $attachment_id = intval($_POST['postid']); 
  3. if ( empty($attachment_id) || !current_user_can('edit_post', $attachment_id) ) 
  4. wp_die( -1 ); 
  5.  
  6. check_ajax_referer( "image_editor-$attachment_id" ); 
  7. include_once( ABSPATH . 'wp-admin/includes/image-edit.php' ); 
  8.  
  9. $msg = false; 
  10. switch ( $_POST['do'] ) { 
  11. case 'save' : 
  12. $msg = wp_save_image($attachment_id); 
  13. $msg = wp_json_encode($msg); 
  14. wp_die( $msg ); 
  15. break; 
  16. case 'scale' : 
  17. $msg = wp_save_image($attachment_id); 
  18. break; 
  19. case 'restore' : 
  20. $msg = wp_restore_image($attachment_id); 
  21. break; 
  22.  
  23. wp_image_editor$attachment_id, $msg); 
  24. wp_die();