Today I stumbled upon a problem, which I think it should be common sense to have in WordPress. I wanted to list the default WordPress image galleries from posts in the loop, but I couldn’t find any shortcode to limit the displayed number of thumbnails. After spending 2 hours on research I’ve found some solutions to this problem, but I had to dig in to the functions.php of my theme.
The solution is to modify the GALLERY shortcode with filters from your functions.php file and then define in a variable how many thumbnails you want in the loop, which will be interpreted by a function.
More "How to limit WordPress gallery thumbnails in the loop"