Add scan for media gallery functionality.

Please don't accept this pull request until after M35 hits stable, but let me know if you have any comments.