fix counting of images when there are more than 10
dont use a global image cache, it must be done per post (otherwise processing multiple posts in the same file will end up with the wrong images)