How to get access all images of custom directory in twig template?
The path will be wrong, file_scan_directory() will return a relative path, you need to add the base_path(), you can set a variable in preprocess:

$variables['base_path'] = base_path();


So...

&lt;img src="{{ base_path }}{{ file.uri }}" width="100%" height="100%" alt="{{ file.name }}"/&gt;