improved link replacing
added media link detection