How to limit number of galley images?

Using a simple xpath expression, you could manage to limit gallery images. 
For example, if you add the following expression to end of your gallery XPath 
then it will only download 5 images:
[position() < 5]