Added checks to make sure the media is an array.