fixed bug to close the media tag