The former middle school religion teacher shared the photos online, using a child’s real name, with an undercover agent, court records say.