Former Glee actor Mark Salling, 35, pleaded guilty to possession of child pornography, and will spend up to 7 years in prison. His prison term will be followed by up to 20 years of supervised release. In addition, he will also have to register as a sex offender for the rest of his life. The plea agreement stems from a federal indictment filed last year, charging Salling with two counts of possession of child pornography.

Mark Salling admitted to downloading more than 50,000 images of child pornography and erotica.

Investigators arrested Salling in December 2015. His ex-girlfriend alerted the authorities. He allegedly showed her the offensive material in the context of the sexual relationship, according to authorities. Court documents reveal that federal investigators discovered thousands of images and videos. Some showed children as young as 2-6 years old.

Per his guilty plea, Salling will spend between 4-7 years in federal prison. Upon his release, he’ll be required to register as a sex offender for life. He will be barred from coming within 100 feet of schools, playgrounds, or other places frequented by children.

Still, the guilty plea is an about-face for Salling. He initially pleaded not guilty to two counts of possession. However, Salling delayed the trail when he sought new legal counsel. He paid $100,000 of the $150,000 bond for his release.

The arrest shocked fans of the show. It didn’t surprise former co-star Naya Rivera, however.

After his arrest, Rivera called him a “dark soul” and told Entertainment Tonight, “I just always felt like there was something he was wrestling with.” Rivera and Salling starred on the hit show together from 2009 – 2015. The court has not schedule sentencing yet. Salling and his representatives have not commented on the plea.

Also read:

(Image: Facebook/NBC DFW)