Check for a valid image in HREF and add class accordingly