' . __METHOD__ . '()' ); check_ajax_referer( $this->identifier, 'nonce' ); global $ewww_force; if ( empty( $_POST['ewwwio_size'] ) ) { $size = ''; } else { $size = sanitize_key( $_POST['ewwwio_size'] ); } if ( empty( $_POST['ewwwio_attachment_id'] ) ) { $id = 0; } else { $id = (int) $_POST['ewwwio_attachment_id']; } if ( empty( $_POST['ewwwio_id'] ) ) { return; } $ewww_force = ! empty( $_REQUEST['ewww_force'] ) ? true : false; $ewwwio_id = (int) $_POST['ewwwio_id']; global $ewww_image; $file_path = ewww_image_optimizer_find_file_by_id( $ewwwio_id ); if ( $file_path && 'full' === $size ) { ewwwio_debug_message( "processing async optimization request for $file_path" ); $ewww_image = new EWWW_Image( $id, 'media', $file_path ); $ewww_image->resize = 'full'; list( $file, $msg, $conv, $original ) = ewww_image_optimizer( $file_path, 1, false, false, true ); } elseif ( $file_path ) { ewwwio_debug_message( "processing async optimization request for $file_path" ); $ewww_image = new EWWW_Image( $id, 'media', $file_path ); $ewww_image->resize = ( empty( $size ) ? null : $size ); list( $file, $msg, $conv, $original ) = ewww_image_optimizer( $file_path ); } else { if ( $ewwwio_id && ! $file_path ) { ewwwio_debug_message( "could not find file to process async optimization request for $ewwwio_id" ); } else { ewwwio_debug_message( 'ignored async optimization request' ); } return; } ewww_image_optimizer_hidpi_optimize( $file_path ); ewwwio_debug_message( 'checking for: ' . $file_path . '.processing' ); if ( ewwwio_is_file( $file_path . '.processing' ) ) { ewwwio_debug_message( 'removing ' . $file_path . '.processing' ); $upload_path = wp_get_upload_dir(); ewwwio_delete_file( $file_path . '.processing' ); } } }