Hey,
I have a gallery and I want to display the first five images separately.
gallery:
type: files
layout: cards
image:
cover: true
info: "{{ file.dimensions }}"
I tried " isNth()" but but the displayed images do not match the position.
<?php $images = $page->gallery()->toFiles();
foreach($images as $image): ?>
<?php if ($image->is($images->first())): ?>
<img src="<?= $image->url() ?>" alt="">
<?php endif ?>
## Shows the first image in the gallery
<?php if ($image->isNth(2)): ?>
<img src="<?= $image->url() ?>" alt="">
<?php endif ?>
## Shows the THIRD image in the gallery
<?php if ($image->isNth(3)): ?>
<img src="<?= $image->url() ?>" alt="">
<?php endif ?>
## Shows the FOURTH image in the gallery
<?php if ($image->isNth(4)): ?>
<img src="<?= $image->url() ?>" alt="">
<?php endif ?>
## Shows the SIXTH image in the gallery
<?php if ($image->isNth(5)): ?>
<img src="<?= $image->url() ?>" alt="">
<?php endif ?>
## Shows the ELEVENTH image in the gallery
<?php endforeach ?>
Is there another opportunity?
THX