0

in hook_file_download there is just a parameter named uri. How can I get nid of the node that contains the file in uri?

For exmpale I have a file field in my content type.I create a node and add some files to file field. Now when this file is going to be downloaded, in hook_file_download I want to get nid of the file.How?

2

If this is an file attached through a file or image field, you can instead implement hook_file_download_access(), which gives you the $field, $entity_type and $entity to which the file belongs.

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.