I have this action that retrieves the crop values when I crop an image in the image editor and update the value in the db record (with update_field()
.
So I can update the value of the field in the database, but I don't know how to set the value of the field in the post editor. The field value remains blank and when the user update the post the value is being overwritten by with null value.
How can I do?
add_action( 'wp_save_image_editor_file', 'save_crop_data');
function save_crop_data(){
$attachment_id = $_REQUEST['postid'];
$parent = get_post_ancestors($attachment_id);
$post_id = $parent[0];
update_field('crop_data', $_REQUEST['history'], $post_id);
return $saved;
}