I'm curious to know if it's possible the following:
In the Post Edit Form, when the user decides to change the images (custom image field) by deleting the current pictures so they can upload the new ones, how can I make sure that the delete pictures are deleted permanently from the database and not just from the custom fields?
Similarly, when the user decides to delete his/her custom post, how can I make sure that the pictures attached to the custom post are also deleted permanently?
Thanks for the help.
Both of these will require a significant amount of custom code, and unfortunately I don't have cut-and-paste solutions available that will do exactly what you're looking for. The Forms API offers some event hooks that might be helpful. For the Post Edit Form, you can use the cred_before_save_data hook to inspect the existing custom field values in a post, and also inspect the incoming updates. If the updated file name is empty or different, use the WordPress API to delete the existing image file(s) permanently using wp_delete_attachment:
https://codex.wordpress.org/Function_Reference/wp_delete_attachment
When deleting a post you can use the before_delete_post hook as described in the WordPress documentation here: https://codex.wordpress.org/Plugin_API/Action_Reference/before_delete_post
Within that callback you can use get_post_meta to inspect the values of any custom image fields in the post. Then you must somehow identify those attachment posts in the database by ID (this might be difficult if you're renaming image files upon upload), and delete those posts using wp_delete_attachment: https://codex.wordpress.org/Function_Reference/wp_delete_attachment
My issue is resolved now. Thank you!