Having a past affair can't be a ground for divorce. Even if the ex boyfriend has published the photos online, this is not a ground as per the law. In fact the ex boyfriend has committed an offence by publishing such pictures. Be that as it may, if the husband is really keen on getting divorce, then he will have to allege cruelty as a ground for divorce.
You must consult a local lawyer with all the evidence and data so that proper grounds can be formulated based on the information.
Regards,