Two hapless burglars were caught as they tried to break into an empty derelict carpet warehouse - six years after it closed down.
Damian Uddin and Kyle Stanhope were arrested over the failed raid at the former Carpetright building near to Castleford town centre.
Leeds Crown Court heard how a resident living opposite the building on Albion Street rang police after seeing three men dressed in balaclavas and dark clothing trying to break in.
One of the men ran off along nearby railway lines and managed to escape.
Uddin and Stanhope got into a red Subaru vehicle parked nearby as police arrived on the scene.
Uddin drove the vehicle at a police car and rammed it five times to stop it blocking his path.
Read more: Drunk driver injured child in head-on crash in stolen taxi
He then drove the car at triple the speed limit as he tried to get away.
Peter Yates, prosecuting, said the vehicle reached 90mph in a 30mph area as Uddin drove towards Methley.
He drove on footpaths and took blind bends on the wrong side of the road during the seven minute pursuit.
The West Yorkshire Police helicopter was deployed during the incident.
The pair abandoned the car in Methley and ran off.
Uddin was found hiding in a ditch and Stanhope was found hiding under a bridge.
Read more: Murder trial date set for teenager accused of stabbing man to death during Leeds West Indian Carnival weekend
Uddin, 30, of Merewood Close, Castleford, pleaded guilty to attempted burglary, dangerous driving and having no insurance.
He was jailed for 26 months and banned from driving for 43 months.
The court heard Uddin has previous convictions for theft, burglary and handling stolen goods.
His barrister, Richard Canning, said he had pleaded guilty to the offences at an early stage.
Mr Canning said Uddin had driven dangerously when he panicked after police arrived at the scene.
Stanhope, of Sugarhill Close, Oulton, Leeds, pleaded guilty to attempted burglary.
His barrister, Sean Smith, said Stanhope had been in custody since in the offence.
He was given a six month sentence.