Hi,
I am using node_save($node) because of thousands node importing. So I am using this code:
...
...
...
while($i < count($images_product_main)){
if(file_exists($images_product_main[$i])){
$field = content_fields('field_main_image');
$validators = array_merge(filefield_widget_upload_validators($field), imagefield_widget_upload_validators($field));
$files_path = 'sites/default/files/images/import/' . $katalog;
$file = field_file_save_file($images_product_main[$i], $validators, $files_path);
//dsm($images_product_main[0]);
$nody->field_main_image[0] = $file;
break;
}
else {
$i++;
}
}
...
...
...
node_save($nody);
If I run this script more than one time the file (e.g. "first.jpg") is copied like "first_1.jpg" or "first_2.jpg".
I can't find any preference settings for your module so I guess there are none.
My Question: Does your module supports such customs "node_save()" actions? If yes... do I have to change something? :)
Greetings
CKIDOW
Comments
Comment #1
markDrupal commentedIt wasn't tested for this work flow.
This module depends on a call to the function file field module function:
field_file_save($node, &$file)which is called by CCK at some point during the node save operation.I couldn't trace the function running during a node_save($node) call. But It might be called automatically. Give it a test and let me know.
You might also want to try changing one line of your code above
$nody->field_main_image[0] = $file;TO
$nody->field_main_image[0] = field_file_save($node, $file);That would insure that the upload_replace module is run at least once during the script you wrote. Although that change might force it to run twice, affecting performance.
Comment #2
markDrupal commented