Get rid of MANY sql queries when moving the mouse

... by caching the count of images in the current query.