In gallery check that the OP actually has an image before substracting it to the image number