cajames / kirby-editor-gallery-block

A gallery block for the Kirby Editor
MIT License
61 stars 5 forks source link

Index of current image and count() of all images in each gallery? #22

Open larshoie opened 4 years ago

larshoie commented 4 years ago

Hey!

I really love the plugin, thanks so much for making it!

I'm trying to do something kind of like a slideshow and I'm wondering if it's possible to get the index of the current image and the count() of all images in each gallery block?

In the gallery.php snippet I've tried this (which I found on the forum)

<?php 
    $total = $images->count();
    ...
    ...
?>

and then in the loop I would like to be able to do something like this:

<?= $images->indexOf($image) + 1 . "/" . $total;?>

Currently when I try this I'm getting this error: Method Kirby\Editor\Blocks::__toString() must not throw an exception, caught Error: Call to a member function count() on array