0

I've URL which is mapped to file field (image) via Feed Ex.

I'm trying to change the filename before it's get saved using tamper plugins (e.g. concat or regex), however it is also changes the requesting URL causing saving the invalid image files which consist html with 404 error.

How do I use Feeds Tamper plugin to modify data (filename) after the file is downloaded but before it's get saved? Or I need to find some other alternative way of doing that?

1 Answer 1

0

It seems it's not possible using tamper plugins (as far as I've tried).

As workaround, this can be achieved by using hook_file_presave(), for example:

/**
 * Implements hook_file_presave().
 */
function mymodule_file_presave($file) {
  if ($file->filename == 'ShowImageXML.asp') {
    $filename = date("ymd", $file->timestamp) . '-' . $file->filesize . '.jpg';
    $uri = 'public://images/' . $filename;
    $file = file_move($file, $uri);
  }
}

See also a feature request: #2596841

Your Answer

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

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