I have an image field that I am trying to save multiple images to. There is one field but when I set up the array, only the first image fid is saved.
$i = 0;
foreach ($photos as $photo) {
// make sure we actually retrived this particular image
if ($photo['Success'] == TRUE) {
// setup the filename and filepath, then write the file to disk
$filename = "{$id}-{$number}.jpg";
$filepath = "public://drealty_img/{$filename}";
// Create image object
$file = file_save_data($photo['Data'], $filepath, FILE_EXISTS_REPLACE);
// add this image to the content entity
$content->images = array(
'und' => array(
$i => array(
'fid' => $file->fid,
),
),
);
} // endif $photo['Sucess']
$i++;
} // endfor $photos
Am I saving the image field incorrectly? Or is there something that needs to be set up to allow for multiple images to be saved?