How do I get the number of each image on a page?

I try to get the number of each image from a page. I can count how many images a page have, with something like $gallery->count(), but I don’t know how to display/show the number of an image.

Example: I have a gallery and I want to show the number under each image of this gallery.

Please let me know if you need any clarification.

indexOf() is what you want here:

foreach ($gallery as $image) {
  echo $image;
  echo $gallery->indexOf($image) + 1; // add 1 because index starts at 0
}

It’s exactly what I need, sorry to not find this in the documentation :pray: