Add image cache function