However, you could hook into the image update_value action and look for an empty value. If found, you could lookup the old value (get_field) and then use the ID to remove it from the DB completely.
You can target all image update_value actions like so:
function my_acf_update_value( $value, $post_id, $field )
// do something else to the $post object via the $post_id
add_filter('acf/update_value/type=image', 'my_acf_update_value', 10, 3);
No, the above code will not delete images.
It is a demonstration of how you can hook into the update_value filter and delete it with code.
Please remember that this is a support forum, not a free development service. I can point you in the right direction with functions, docs and general help, but I will not write your custom code for you.
Do we have to use a specific field name for this, to get the previous value? I mean does this apply: get_field($field, $post_id) or we have to specify a field name like this ‘get_field(‘field_name’, $post_id)’. could you possibly write this tutorial, it would be much appreciated. Anyone found a solution on this?
Viewing 6 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users