While adding images in a post with the gallery shortcode, I want to display an image number as title of the image e.g if there are 3 images in a gallery and displayed as a list, above each image there should be a serial number.
Shown as
I can set it afterwards with inline css. I tried alot in media.php
, but without success.
Set a custom function between the gallery shortcode handler and the output. Catch the
img
elements and add a static counter. Then return the gallery output to WordPress.Sample code:
This will insert a
<span class='gallery-number'>1</span>
into the link. You can position it in CSS with: