Fix JS error when adding new media