A judge who jailed two men after mobile phone footage of a “happy slapping” beating was posted on Facebook warned others that similar “outrageous” behaviour would lead to prison.

Paul Hirst, 29, and Ian Hobbs, 30, were each locked up for six months for attacking homeless Gary Morgan with a knuckle duster, capturing the assault on Hobbs’s phone.

Prosecutor John Bull said film of the incident, in the street outside Hobbs’s home, was uploaded on to Facebook with the words: “Put that in your MC baghead”.

Hirst, of Norman Avenue, Eccleshill, and Hobbs, of Ryedale Way, Allerton, pleaded guilty to causing Mr Morgan actual bodily harm on September 12 last year and having a knuckle duster as an offensive weapon.

Mr Bull said the three men were friends and Hobbs offered Mr Morgan a home after they contacted one another on Facebook.

Mr Morgan left the house on the day of the assault, leaving an empty bottle of the hard drug substitute methadone in his bag in a bedroom.

Hobbs and Hirst, who had been drinking, were furious when a young child visiting the house found the bottle. When Mr Morgan returned, Hirst punched him twice in the face and Hobbs swung at him with the knuckle duster.

Hirst then continued the attack, goaded and encouraged by Hobbs who filmed it on his phone. Mr Morgan suffered a black eye, facial cuts, swellings to his head and scratches to his back.

Mr Bull said that he and Hirst burst through a hedge into a neighbour’s garden during the struggle.

Mr Morgan said he was left pyschologically damaged, with stress, anxiety and sleepless nights.

“That is the sort of conduct that has to be met with an immediate custodial sentence to mark the outrageous nature of that kind of offending,” he said.

Judge Benson said both defendants were enjoying the incident, either because of their drinking, or their perverse pleasure in inflicting pain and humiliation on Mr Morgan.