refactor mediaGallery to support multiple pages; bug 870982