A pair of bungling burglars were caught out as they tried to break into a 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 into the premises.
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 fivetimes to stop it blocking his path.
He then drove the car at three times the speed limit as he tried to get away.
Peter Yates, prosecuting, said the vehicle reached up to 90mph in a 30mph area as Uddin drove in the direction of 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 then abandoned the car in Methley and tried to run off.
Uddin was found hiding in a ditch and Stanhope was found hiding under a bridge.
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 should be given credit for pleading guilty to the offences at an early stage in the proceedings.
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.