How do I display multiple images on the page with kirby-builder?
<?php foreach($data->media()->toFile() as $item): ?>
<img src="<?= $item->url() ?>" srcset="<?= $item->srcset() ?>" >
<?php endforeach ?>
I’m getting an error of
Call to a member function url() on null
Assuming that media
is a files field with multiple files:
<?php foreach($data->media()->toFiles() as $item): ?>
<img src="<?= $item->url() ?>" srcset="<?= $item->srcset() ?>" >
<?php endforeach ?>
toFile()
is only for a single file object, you can’t loop through.
Awesome thank you, I should of caught that