Fix figures counter: Do not increment for images that are not figures

Counter of figures was being incremented even if the image was not a figure (i.e. asterisk as title), leading to generation of incorrect labels for figures.