Images and their thumbs in one loop

Hi everybody
I’m on my first kirby-project and I use this code (from the kirby cook book) to get all images in my content root.
Now id like to echo each thumbnail aswell.
How can I do this?

		<?php foreach($site->images() as $item): ?>
			<img src="<?php echo $item->url() ?>">
	<?php endforeach ?>

Works the same way, just use the thumb() helper.

See: https://getkirby.com/docs/templates/thumbnails

or the resize function each file/media object has. its a wrapper for thumb afaik.

https://getkirby.com/docs/cheatsheet/file/resize

Thank. I’ve allready seen those pages of the documentary. But I’m not a php hero. So how does this specific loop has to look? I’ve tried some modifications but they all ended i a rendering error.

<?php foreach($site->images() as $item): ?>
  <img src="<?= $item->resize(300)->url() ?>">
<?php endforeach ?>

Oh wow, that’s cool!
Some seconds ago a broght this to life:

<?php foreach($site->images() as $item): ?>
	<img class="slide" src="<?php echo thumb($item, array('width' => 700))->url() ?>">
<?php endforeach ?>

But that’s a lot of code compared to yours :wink:

While longer, the thumb method is perfectly ok, though.

So this is my final code for a little srcset:

<?php foreach($site->images() as $item): ?>
<img src="<?php echo $item->url() ?>" srcset="<?php echo $item->resize(900)->url() ?> 500w, <?php echo $item->url() ?> 1500w" alt="Stimmungsbild">
<?php endforeach ?>

Thank you for your help.