Check if file is a png

I normally do something like this… you can repeat it for other extensions…

<?php foreach($labs->filterBy('extension', 'pdf') as $pdf): ?>
<a href="<?= $pdf->url() ?>"><i class="fa fa-file-pdf-o"></i><?= $pdf->filename() ?> (<?= $pdf->niceSize() ?>)</a> 
<?php endforeach ?>

I think yours isn’t working since its missing file()

<?= $thumbnail->file()->extension(); ?>

It’s not clear from your code example how you are finding the files to work with. Where and how are you setting the $labs variable?