I'm using hook_node_insert to process some data from node.

This code returns image URL, BUT i'm using FileField Paths and i can't manage to get the final image URL. Is there any way to solve this issue?

$fid = $node->field_imagen['und'][0]['fid'];
$imgpath = file_load($fid)->uri;
$url = file_create_url($imgpath);



Filefield Path uses hook_entity_insert() to operate with file directory. The hook_node_insert is called before hook_entity_insert, so the file isn't processed yet there. See: https://api.drupal.org/api/drupal/modules%21node%21node.module/function/node_save/7

module_invoke_all('node_' . $op, $node);
module_invoke_all('entity_' . $op, $node, 'node');

You should use that hook as well. Just make sure, your module have higher weight than ffp. (Check (and increase if necessary) the weight field of your module in the system table.)

| improve this answer | |
  • I've been trying to make it work but i can't. Where should i use module_invoke_all and how do i get the vars from it? I can only get the final image url from entity_insert, but i can't pass the variable to node_insert... what about module_invoke('filefield_paths', 'entity_insert', $node, 'node')? – Federico Arena Sep 27 '13 at 13:33
  • It was just a part of node_save, you never need to use that code. Just do whatever want you do, but not in you module MODULE_node_insert function, do it in MODULE_entity_insert. :) – Gabor Szanto Sep 27 '13 at 15:43

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.