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