Added optional container id (default is the image element's parent), checked if image to create thumbnail for is already loaded