Use ->images() method on folder, e.g. /assets/images

I’ve written a little snippets that creates a banner from images I supply. It would be nice if it could gather the images from a folder automatically. I would like to do something like
foreach($assets/images->images() as $image)…

(i.e. analogous to
foreach($page->images() as $image)…)

I’ve found something about Assets and Media classes, but wasn’t quite sure if this is what I’m looking for.
Any hints would be appreciated.
Thanks

Try:

<?php foreach(dir::read(kirby()->roots()->assets() . '/images') as $img) {
  $img = new Asset('assets/images/' . $img);
  echo $img->resize(200);
}
?> 
1 Like

Thanks for your super-quick reply. Works like a charm!

Just one more thing: don’t forget to always check if you really have the right object before you call an object method on it.