Vivien Killilea via Getty Images Mark Salling attends an event in 2015.

“Glee” star Mark Salling pleaded guilty to possession of child pornography involving prepubescent minors as part of a plea deal on Wednesday, according to court documents obtained by Deadline.

The 35-year-old actor could face four to seven years in prison followed by up to 20 years of supervised release. He must register as a sex offender and is banned from communication with anyone under age 18 without a legal guardian or parent present. Salling will also pay $50,000 in restitution to each victim who requested it.

The actor was arrested in December 2015 on suspicion of possessing “hundreds” of images plus two videos featuring underage girls on his personal computer after his ex-girlfriend reportedly alerted authorities. In fact, federal investigators discovered tens of thousands of pornographic images and hundreds of videos with children ages 2–6 on a hard drive, according to court documents.

After his release, Salling will be restricted from going within 100 feet of schoolyards, parks, public swimming pools, playgrounds, video arcades or any place frequented by minors. He must also enroll in a sex offender treatment program.

The decision comes more than a year after Salling pleaded not guilty following a federal grand jury indictment on two counts of possessing child pornography. The trial, however, was delayed as he sought new legal representation.

While the charges sent shockwaves through the “Glee” fandom at the time of his arrest, co-star and former girlfriend, Naya Rivera, wasn’t entirely surprised.

“He always was a very dark soul to me,” Rivera told Entertainment Tonight about Salling. “I just always felt like there was something he was wrestling with.”

HuffPost has reached out to Salling’s representatives for a statement and will update this post accordingly.