Checking if the image is hidden before doing anything else

This way we avoid doing unnecessary work in case the image is actually
hidden