Support

Account

Home Forums Add-ons Repeater Field Repeater field images to Gallery Image

Unread

Repeater field images to Gallery Image

  • I have a submission form on my website, I try to get images from the repeater field to gallery images and it’s work. I have just followed John Huebner answer here:
    https://support.advancedcustomfields.com/forums/topic/repeater-field-images-to-woocommerce-gallery/

    But, the problem is, when I tried to edit the gallery image, I added a new image, but the new image wasn’t updated. Only the image of the form submission is there.

    Any idea how to get this done?

    // Set Repeater Image as Gallery Images
    function my_acf_save_post($post_id) {
        $repeater = 'preview_images_row';
        $subfield = 'preview_images_file';
    
        // using get_post_meta because that way we're sure to get the image ID
        $count = intval(get_post_meta($post_id, $repeater, true));
        $images = array();
        for ($i=0; $i<$count; $i++) {
            $field = $repeater.'_'.$i.'_'.$subfield;
            $images[] = intval(get_post_meta($post_id, $field, true));
        }
        update_post_meta($post_id, 'preview_images', $images);
    }
    add_action('acf/save_post', 'my_acf_save_post', 20); // priority of 20 so it runs after ACF

    See the video here: https://jumpshare.com/v/qEm3KlfMejXw2Li7Txfs

Viewing 1 post (of 1 total)

The topic ‘Repeater field images to Gallery Image’ is closed to new replies.