This will work. It will add a meta box below the content editor window which outputs anything you put in the get_preview_image()
function. I’ve included the $post
argument so you can grab info from the post.
If you need this to be on a custom post type instead of posts, edit where it says ‘post’ in the image_preview_add_meta_box()
function.
add_action( 'some_image_preview', 'get_preview_image', 10, 1 );
function image_preview_add_meta_box() {
add_meta_box(
'image_preview-image-preview',
__( 'Image Preview', 'image_preview' ),
'image_preview_html',
'post',
'normal',
'high'
);
}
add_action( 'add_meta_boxes', 'image_preview_add_meta_box' );
function image_preview_html( $post ) {
wp_nonce_field( '_image_preview_nonce', 'image_preview_nonce' );
do_action( 'some_image_preview', $post );
}
function get_preview_image( $post ) {
echo 'This is cool!';
}