Quantcast
Channel: Tagged with repeater - Plugin Support
Viewing all articles
Browse latest Browse all 160

Problems updating repeater with image field

$
0
0
Hi, I'm not sure if this is a bug or a feature, but the behavior I'm seeing seems very odd!

I have a repeater field called "images" which has one sub field - "image".

I am running code to create media objects and then add them to the repeater. The code that does the updating is as follows (my repeater field key is "field_7"):



$field_key = "field_7";
$value = get_field($field_key, $post_id);
$value[] = array('image' => $media_id);


The first time my code runs, and a single image is added, all is well. The media post if created and the id is stored in the database in the repeater field. The db rows look like this:


post_id meta_key meta_value
623 images 1
623 images_0_image 624


However, when I run the same code again - trying to add another image to the repeater - when retrieving the value using get_field, the value returned is now a URL (string) and not a integer! So when I add a new media object to the repeater my db rows look like:


post_id meta_key meta_value
623 images 2
623 images_0_image http://192.168.0.2/benprop/wp-content/uploads/2013...
623 images_1_image 625


And this doesn't work in the ACF front end - the repeater field stored as an int shows, but the original image, now stored as a string, doesn't show...

Does anyone have any idea what I'm doing wrong?

Viewing all articles
Browse latest Browse all 160

Trending Articles