make it work with external images, too