Hi We can archive to add custom script and ajax functions.
Step 1: Create the option to upload image using ACF custom fields plugin in the 3D flip post type.
Step 2 : add this script to the footer.php in your active theme.
<script type="text/javascript">
(function($) {
jQuery(document).ready(function() {
var ajaxurl = "<?php echo admin_url('admin-ajax.php'); ?>";
jQuery("._3d-flip-book").each(function() {
var El_img = jQuery(this ).find('img');
// El_img.addClass("test");
var post_id = jQuery(this ).data('id');
var data = {
'action': 'change_thumbnail_3d_flip',
'post_id': post_id,
// 'security': '<?php //echo wp_create_nonce("changethumbnail3dflip"); ?>'
};
$.post(ajaxurl, data, function(response) {
if(response.success){
var result = $.parseJSON(response.data);
console.log(result.image_url);
if(result.image_url != 0){
El_img.attr('src', '');
El_img.attr('src', result.image_url);
}
}
});
});
});
})(jQuery);
</script>
Step 3 : Add this code to your functions.php file.
add_action('wp_ajax_change_thumbnail_3d_flip', 'change_thumbnail_3d_flip_callback');
add_action('wp_ajax_nopriv_change_thumbnail_3d_flip', 'change_thumbnail_3d_flip_callback');
function change_thumbnail_3d_flip_callback()
{
// check_ajax_referer('changethumbnail3dflip', 'security');
$post_id = $_REQUEST['post_id'];
$image_url = 0;
if(!empty($post_id)){
$image_obj = get_field('upload_thumbnail', $post_id);
if( !empty( $image_obj ) ){
$image_url = $image_obj;
}
}
$response['image_url'] = $image_url;
$response = json_encode($response);
wp_send_json_success($response);
wp_die();
}
Step 4 : Upload your thumbnail in 3D flip
now it will working fine. i am using the same