Implements hook_file_download_access().
function node_file_download_access($field, EntityInterface $entity, File $file) { if ($entity ->entityType() == 'node') { return node_access('view', $entity); } }