A former Playboy model, Danielle Mathers, has been sentenced to community service for secretly photographing a naked older woman in a Los Angeles gym and then posting the picture on social media, court documents and officials said.

According to the criminal complaint, Ms. Mathers, 30, was charged in Los Angeles Superior Court in November 2016 for using a “concealed” camera to take a photograph of the woman, who was 70 at the time, in July and then posting it online.

Ms. Mathers “uploaded the photograph to her Snapchat account, with comments about the woman’s appearance and a picture of Ms. Mathers covering her mouth,” the Michael N. Feuer, the Los Angeles city attorney, said in a written statement on Wednesday.

The police investigated, acting on a tip from LA Fitness officials.

Mr. Feuer said that Ms. Mathers entered a plea of no contest to a misdemeanor invasion of privacy charge on Wednesday and will perform 30 days of community labor. She was also placed on probation for three years, according to the city attorney’s office.