0

I'm trying to import external nodes from html pages. all working fine but i just cannot make image getting saved in a subfolder.

am mapping a uri value "public://posts/2014/03/4587214.jpg" to "image:uri" and i want the file to be saved in "sites/default/files/posts/2014/03/4587214.jpg" but the file is getting saved in "sites/default/files/posts/4587214.jpg" instead . ("posts" is the value of the subdirectoy in the content type)

any advice on how to make feeds save images in subfolders ? (and create these on fly if do not exist)

i can do it by hacking "feeds/mappers/file.inc" and changing the value of $destination variable as follows:

case 'uri':
if ($v) {
try {
/* patch - start */
/* added to allow subfolder destination */
$uri = $v->getValue();
$uri_target = file_uri_target($uri);
$uri_scheme = file_uri_scheme($uri);
$uri_path_info = pathinfo($uri_target);
$destination = file_stream_wrapper_uri_normalize($uri_scheme . "://" . $uri_path_info['dirname']);
/* patch - end */
$file = $v->getFile($destination);

but i was wandering if this can be done without hacking feeds source files

0

1 Answer 1

1

My solution to a similar problem was installing FileField module and in the content type design, put the attached files (as images in the example) in a structured folder by tokens.

This way, when feeds grab the image and attach to node, file_fields module gets the task and put the image into a folder as you mention by design.

It's also helpful when you add single content, not bulk import operations.Everything organized just as you plan.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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