A former candidate for St. Paul City Council avoided additional jail time when he was sentenced Friday for posting a topless photo of his wife online while he was running for the city’s Ward 4 seat.

Ramsey County District Judge Robert Awsumb placed David Martinez on probation for the next two years and ordered that he receive a mental health evaluation, avoid drugs and alcohol and refrain from having contact with his wife on one count of non-consensual dissemination of private sexual images.

If Martinez doesn’t follow the terms, he’ll be sent to jail for close to a year. He was given credit for the 12 days he spent in jail following his arrest in the matter.

The sentence was less than the term recommended in state sentencing guidelines.

Martinez already spent 12 days in jail following his arrest

Martinez, 39, pleaded guilty to the crime in March after previously denying it.

As part of his plea deal, prosecutors agreed that the felony charge would be sentenced as a gross misdemeanor.

Martinez posted the topless photo on his campaign website last July 14, one day after his estranged wife filed for an order for protection against him, according to court records.

Martinez initially denied posting the image and said his campaign website had been hacked.

The incident was one of several legal issues Martinez was allegedly involved in during his campaign for public office.

His run ended last August when he lost to Mitra Jalali Nelson in a special election.