Directory smush gets stuck after 5000 images

When using directory smush with over 5000 images it will stop at 5000th image and will not optimize any images after that.
Using subfolder with less images will work however.

It looks like there's 5000 limit to split the query but it doesn't go over to next 5000.