Im struggling to get data out of Kirby Builder. I have set the Gallery plugin up inside a Builder field, but when i trying and get the data out of the gallery field, its not returning what i need.
I have this in a builder snippet. The gallery field is called slide:
<?php if ($data->slide()->isNotEmpty()): ?>
<section class="swiper-container slideshow">
<div class="swiper-wrapper">
<?php foreach($data->slide()->toStructure() as $image): ?>
<?php $imageitem = $image->toFile();?>
<div class="swiper-slide"><?= $imageitem ?></div>
<?php endforeach ?>
</div>
<div class="swiper-button-prev"></div>
<div class="swiper-button-next"></div>
</section>
<?php endif ?>
The problem is, the <?= $imageitem ?>
gives me a full image tag. All i want is the URL and to be able to access things like the image width and the images meta data so i pull it alt tag from the images meta file. If try and do <?= $imageitem->url() ?>
. I have also tried using yaml instead of toStructure (i know toStructure is better) and got the same result. A stab in the dark really.
The content looks like this:
Builder:
-
slide: |
- kioski-thinking-particles-explsn01.jpg
- kioski-thinking-particles-explsn02.jpg
- kioski-thinking-particles-explsn03.jpg
- >
kioski-thinking-particles-explsn04_tp.png
toggle: 'true'
_fieldset: slideshow
The blueprint looks like this:
builder:
label: Show and Tell
type: builder
fieldsets:
singleImage:
label: Single Image
snippet: builder/singleimage
fields:
picture:
label: Image
type: image
toggle:
label: Is this a featured work?
type: toggle
text: yes/no
width: 1/3
slideshow:
label: Slideshow
snippet: builder/slideshow
fields:
slide:
label: Slides
type: gallery
toggle:
label: Is this a featured work?
type: toggle
text: yes/no
width: 1/3
video:
label: Video
snippet: builder/video
fields:
vid:
label: Video URL (Vimeo or Youtube)
type: text
toggle:
label: Is this a featured work?
type: toggle
text: yes/no
width: 1/3
How can i get all the images data, including meta data?
Thanks