wp_ajax_imgedit_preview()WP 3.1.0

Handles image editor previews via AJAX.

No Hooks.

Return

null. Nothing (null).

Usage

wp_ajax_imgedit_preview();

Changelog

Since 3.1.0 Introduced.

wp_ajax_imgedit_preview() code WP 6.6.2

function wp_ajax_imgedit_preview() {
	$post_id = (int) $_GET['postid'];
	if ( empty( $post_id ) || ! current_user_can( 'edit_post', $post_id ) ) {
		wp_die( -1 );
	}

	check_ajax_referer( "image_editor-$post_id" );

	require_once ABSPATH . 'wp-admin/includes/image-edit.php';

	if ( ! stream_preview_image( $post_id ) ) {
		wp_die( -1 );
	}

	wp_die();
}