Refactor method used to get media gallery images