2

I have an image file field and I am attempting to write a little script that will programmatically scan my nodes and save images found in the body of my node into an image file field entitled field_post_image

I've been looking at the default process of what Drupal 7 + Image Field does and the example on SO found here: https://stackoverflow.com/questions/5129559/attaching-files-to-nodes-programmatically-in-drupal-7

I figured the best practice would be to save the images to the same folder as the file field destination in an effort to keep my /sites/default/files clean of orphaned files etc.

I've looked at both field_info_field and field_info_instance in the Field Info API and I can't seem to find the files destination (as configured in the Field UI)

Am I missing something and/or am I looking in the wrong place?

Thanks!

1

It's part of the instance settings of the file field, but it supports tokens. You want to call file_field_widget_uri($field, $instance), that will give you a URI you can use to save the file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.