Add Media to API (master)

#1034, with docs and tests, submitted against master