A San Francisco gay rights blogger has pleaded no contest to a disorderly conduct charge after taking a photograph of a gay politician in a toilet.

Michael Petrelis snapped a picture of District Supervisor Scott Wiener in a City Hall toilet last October and posted the photo on his blog.

Petrelis had clashed with Mr Wiener over San Francisco’s public nudity ban and other legislation.

A superior court judge sentenced Petrelis to three years’ probation on Thursday and imposed a restraining order requiring him to stay away from the supervisor.

Lawmakers in San Francisco narrowly approved a ban on public nudity in November 2012.

Last September, Mr Wiener pushed for the nudity ban in answer to constituents fed up with seeing naked men hanging out in the heart of the Castro district.

Far from being a “quirky part of San Francisco,” Mr Wiener said the issue had become extreme and required city action.

The area, famous for its LGBT community and the legendary story of gay rights campaigner and politician Harvey Milk, had long been tolerant of public nudity, until the new law was passed.

Those who break the ban face $100 (£62) fines or a year in jail for repeat offenders.