Image copyright Imaginechina/REX Shutterstock Image caption State media said the man was thought to have mental health problems

A man who allegedly randomly attacked a toddler in China's Shaanxi province has been arrested, state media report.

Security camera footage of a man repeatedly stamping on the two-year-old on a pavement in Luochuan County has sparked outrage in China.

It became the most talked-about topic on social media, with many criticising people who passed by without helping.

The child suffered skull fractures but was not in a life-threatening condition, said Xinhua news agency.

The 28-year-old man, surnamed Wang, is believed to have mental health problems, said Xinhua. He was detained late on Thursday.

The video showed the child playing outside a restaurant when a man walks by and suddenly knocks him to the ground.

The man then stamped on the child's head repeatedly. He also used a broom to beat him for at least 30 seconds.

Image copyright Imaginechina/REX Shutterstock

A motorbike rider and a pedestrian passed by before a group of people rushed out of the restaurant to stop the attack.

The video had been viewed more than 17 million times.

The reaction on China's microblogging site Weibo was one of anger, with many, like user Huajianci, asking: "Why [do] some parents let a two-year-old alone?"

Others reacted with hatred towards the attacker including Xingyuxinyuan who posted that "this kind of devil should be sentenced to death immediately".