refactor media_resource