A drug trafficker who tried to smuggle heroin into a prison by flying it in on a drone crashed the aircraft into a garden hut.

John Grant lost control of the aircraft and it crashed with its load of drugs and mobile phones in a residential garden near Saughton prison in Edinburgh.

The grounded device also contained footage on its camera of Grant adjusting settings on the drone and with GPS coordinates of his home address.

The drone was found by a woman in Longstone, who noticed string strewn around her back garden.

When she began to gather it up a black sock fell from the roof of her garden shed.

She then found it was attached to a drone wedged between her hut and fence.

The woman discovered three mobile phones, two chargers and a haul of heroin and diazepam inside the sock.

The High Court in Edinburgh heard that the heroin was worth £11,000 but its value would soar if it had successfully been delivered into prison.

After 47-year-old Grant was identified from film recovered from the drone, a search of his home was carried out where a further half kilo of heroin worth £48,000 was found.

Grant, formerly of Loganlea Terrace in Craigentinny, Edinburgh, admitted being concerned in the supply of heroin between November 5 and 18 last year.

He pleaded guilty to two breaches of Scottish prison legislation by attempting to fly the Class A drug and mobile phones into Saughton on November 5.

Grant also culpably and recklessly piloted "an unmanned aircraft system" at night with its aviation lights taped, making it invisible to other aircraft.

Judge John Morris QC said the accused had admitted a serious of serious charges and jailed him for five years.

Mr Morris described the flying of the drone at night as "reckless conduct in the extreme which could have had catastrophic consequences".

Grant, a former mechanic, was previously jailed for 44 months for a drug trafficking offence.

Footage shown in court showed the accused in his living room operating the drone from an iPad on November 4, the night before the attempt to use it to deliver drugs to Saughton.

The court heard the DJI Phantom 4 drone was launched from waste ground between Scallywags Nursery and Longstone Hearts club on Longstone Road in the early hours of November 5.

Sergeant Graeme Rankin, Police Scotland's Civil Aviation Authority Liaison officer, said: "People need to be aware that a drone is classed as an aircraft and therefore is governed by aviation legislation and people may commit crimes and offences.

"In this instance, a drone was used to attempt to transport illegal drugs and mobile phones into a prison and he has been convicted of a range of offences.

"Please be aware that anyone with access to a drone needs to understand the guidance provided by the Civil Aviation Authority's Drone Safe campaign. We don't want people to be unwittingly committing a crime but it is your responsibility to understand the correct procedures for flying a drone before you do so."