Implements hook_file_download_access().
function user_file_download_access($field, EntityInterface $entity, File $file) { if ($entity ->entityType() == 'user') { return user_view_access($entity); } }