if (replaceImg)
... must before
if (replaceUrl)
...

and also

public static string FormatText(string text, bool replaceBold, bool replaceItalic,
            bool replaceUnderline, bool replaceImg, bool replaceUrl, bool replaceCode, bool replaceQuote)