A teenage boy was caught with 7,528 child porn images on computer equipment when police raided his home in the Hope Valley, Derbyshire.
They included obscene videos and photos of naked boys aged between 10 and 14, Derby Crown Court heard.
The 17-year-old, who cannot be named for legal reasons, admitted eight charges of possessing indecent pictures.
Judge Andrew Hamilton jailed him for six months, suspended for two years and put him on the Sex Offenders’ Register for seven years.
He said: “It is in the public interest that you should be helped rather than punished. “But if you refuse to abide by the help, I am afraid then prison it has to be.”
The teenager will spend two years on probation and must not have equipment which can delete details of internet sites.
Abigail Joyce, prosecuting, said the images were found on a computer and external hard drive.
Sarah Brown, mitigating, said: “When told how many he had actually downloaded, he was shocked.”