A Long Island middle school teacher was fired last week when an old topless selfie that she sent to a boyfriend surfaced — in the hands of a student, according to a new court filing.

Lauren Miranda, a 25-year-old former Bellport Middle School math teacher, was fired Wednesday after a student somehow obtained the image, according to her lawyer, John Ray.

Ray said Monday that officials wrongfully chastised Miranda over the image, which was sent to her then-partner, another teacher at a different school, and eventually fired her for not being a proper school “role model.”

At a press conference, Miranda said the image was obtained without her consent — and that there was nothing inherently offensive about the image anyway.

“It’s pure,” she said of the image that shows her breasts. “I’m getting makeup in one hand, and I’m taking a picture in the other.”

Miranda said she had previously sent the photo to the former flame and had no idea how the student got hold of it.

Miranda and Ray have filed a notice of claim in the case as a precursor to a $3 million lawsuit.

“Long ago, she sent her topless unremarkable selfie to her companion, never to anyone else,” Ray said. “By unknown means, a student obtained it. The school district took possession of it, excoriated her, and fired her because her breasts were displayed.”

Miranda and her lawyer contend that a male teacher would not have been subjected to the same treatment in similar circumstances and that she wants her job back.

“This would never have happened to a male teacher,” Ray said. “The Suffolk County Administrators and School Board have not yet discovered that women are equal to men. Lauren is rightly proud of her female torso. A woman’s breasts are not inherently prurient.”

Miranda said Monday that she wanted to fight back in order to provide a strong example to her former students.

“What kind of role model am I, to now roll over and hide?” she said. “I am showing my face and saying something happened to me that I didn’t want.”

Ray said he didn’t know if the student was ever punished.

Citing pending litigation, district officials declined to comment.