The code
if(link.select("img.a-dynamic-image.a-stretch-vertical").equals(null)){
makes no sense. select returns an Elements collection, which will never be .equals(null). If you want to check whether the select returns anything, use isEmpty or look at the size of the returned collection:
if(link.select("img.a-dynamic-image.a-stretch-vertical").isEmpty()){
// It's empty