It is, but it gets rather involved because you end up copying the entire gallery shortcode handler (gallery_shortcode()) as your own code, even for a very minor change. The good part is you don’t need to understand most of the code, only the part you are changing.
Hook the ‘post_gallery’ filter, passing your version of the handler as the callback. Returning anything from this filter short circuits the default handler and utilizes your return instead. In your version, remove the apply_filters() hook for post_gallery and related code to prevent an infinite loop situation.
The reason you only get one image is the ids argument is passed to get_posts(), which returns only one image attachment object per unique id. To get one image for each occurrence, instead of get_posts(), explode() the ids argument into an array. Step through the array and build an array of attachment objects using get_post() (singular post, not plural posts) for each ID in turn. The rest of the handler remains the same.
-
This reply was modified 8 years, 8 months ago by
bcworkz. Reason: add link to gallery_shortcode()