I just want to let you know that you can get the smaller image (thumbnail, for example) by passing the size to the array. This page should give you more idea about it: https://www.advancedcustomfields.com/resources/image/.
If you still want to pass a smaller size version of the image to another image field, then you can try to insert the file by using the wp_insert_attachment() function, get the image ID, and then update the new field by using the update_field() function like this:
// You need to get the post ID where the new custom field is located. $post_id = 123; // This is a dummy image ID. You should get it by using the // wp_insert_attachment() function $image_id = 99; // Set the new field key. We should use the field key to making sure that // the data is saved correctly $field_key = 'field_1234567890abc'; // Update the field update_field($field_key, $image_id, $post_id);
Also, please keep in mind that you can just update the new field with the original image ID instead. Because ACF saves the image field as the image ID in the database, it won’t need a lot of space. After that, you can just get the smaller size by passing the size to the array.
I hope this helps 🙂
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
© 2022 Advanced Custom Fields.