Hi community
I have a question regarding the display of images that come from a structured content.
In kirby 2 I used to display images from structures as following:
<?php
$toursections = $page->toursections()->yaml();
foreach($toursections as $toursection):
if($image = $page->image($toursection['image'])):
?>
<img src="<?= $image->url() ?>">
<?php
endif;
endforeach;
After migrating to kirby 3 and saving the files (with changed types of image to files), i get the following error:
Argument 1 passed to Kirby\Cms\Page::image() must be of the type string or null, array given, called in /Users/hopper/dev/product-landing-pages-kirby3/site/shared/snippets/iconlistrow.php on line 4
I assume that this is happening, because files returns an array instead of just a string as image did in kirby 2.
Now I kind of worked my way around this with:
if($image = $page->image(A::first($toursection['image']))):
Is there a better or even a proper way, how to get the images out of the structured content?
Thanks in advance for any advice!