Currently looping through a collection of images and setting a custom data-order
using <?= $images->indexOf($img) ?>
. The output is correct, but I would like to change the indexOf() starting position from 0 to 1 so I can use the data-order
value to activate hash URLs in a image carousel on other pages.
Is this possible?
Code below:
<div class="gallery-wrapper">
<?php
$images = $page->images();
foreach ($images as $img):
?>
<div class="gallery-item-wrapper gallery-item-hidden" data-order="<?= $images->indexOf($img) ?>">
<div class="gallery-item <?= $img->align() ?>">
<div class="<?= $img->padding() ?>">
<img class="<?= $img->widths() ?>" src="<?= $img->url() ?>" alt="">
</div>
</div>
</div>
<?php endforeach ?>
</div>
Many thanks!