Former Subway sandwich chain pitchman Jared Fogle on Thursday was sentenced to 15-1/2 years in federal prison after pleading guilty to child pornography and sex charges.

Fogle, who became famous after losing weight on a diet that included sandwiches from the fast-food chain, agreed in August to a deal with prosecutors under which he would plead guilty to charges of child pornography and traveling for illicit paid sex with minors.

Fogle agreed in court on Thursday to avoid pornography, get sexual disorder treatment and will be a registered sex offender. U.S. District Judge Tanya Walton Pratt also sentenced him to a lifetime of supervision.

RELATED: Subway’s Jared: Sex with young boy ‘felt so good,’ secret tapes allege

Dr. John Bradford, a forensic psychiatrist testifying for the defense at the sentencing hearing, said Fogle has "mild" pedophilia and was mostly attracted to older female teenagers 16 and 17 years old, not prepubescent children.

Prosecutors countered the testimony by reading a text from Fogle in which he said he wanted younger prostitutes, "the younger the better."

Bradford also said Fogle has an alcohol problem, and had a compulsive eating disorder that moved into "hypersexuality" after he lost weight.

"He traded a horrible food addiction for a horrible sex addiction," said defense attorney Jeremy Margolis.

Fogle cried during his statement before sentencing, saying his wife and children would never get over this.

"You gave your wife $7 million, she'll be okay," Pratt responded.

RELATED: Former Subway pitchman Jared Fogle makes $1M in payments to victims

Subway fired Fogle when reports of the plea agreement emerged. He has already begun to pay $1.4 million in restitution to 14 victims who are minors.

Federal prosecutors recommended last week that Fogle spend 12-and-a-half years in prison and be under lifetime supervision. After leaving prison, he would also be required to register as a sex offender in any state where he worked or lived.

The sentencing recommendation leaves the door open for further charges against Fogle if other evidence emerges.

Authorities have so far identified 12 victims of child pornography in Indiana, along with two teenage victims of child prostitution in New York, according to court documents.

Fogle has stated that he was sexually attracted to children as young as eight years old, the government said.