If you add it after the `while(next_image()):` line you should be okay. Eg:
`<?php while (next_image()): ?>
<?php printImageTitle(); ?>`
You can move the printImageTitle line around to suit your needs (to put it into a div/span/etc), just make sure the line ends up between the `<?php while (next_image()): ?>` and `<?php endwhile; ?>` lines