The YouTuber, Kanghua Ren said in his defence said that the video was just a "bad joke".

A Spanish YouTube star, who gave a homeless man an Oreo cookie filled with toothpaste, has been sentenced to 15 months in prison. He also owes $22,300 to his victim, The New York Times has reported.

The 52-year-old homeless man reportedly vomited after ingesting the toothpaste cookies. He later said he has "never been treated so poorly while living on the street".

The prankster, known as ReSet to his followers on YouTube, whose real name is Kanghua Ren, was found guilty of violating the moral integrity of the homeless man.

He is unlikely to serve any time behind bars, however, Spanish law normally allows sentences under two years for first-time offenders in nonviolent crimes to be suspended, The New York Times report on Sunday said.

The YouTube star in his defence said that the video was just a "bad joke".

"I do things to mount a show: People like what is morbid," he told the court, according to the Spanish media.

However, the judge noted that Ren had earned more than 2,000 euros from advertising revenues generated by the video, one of several he filmed in response to various challenges received from his followers, the report said.