Suppose, I have this paragraph:
<p>this is a paragraph containing link to an image at http://lol/atme.png :)</p>
I want to replace http://lol/atme.png with an image element.
How do I do that?
Its like removing the text, but adding a image element in place of that text.
Help will be greatly appreciated.
There are two parts to this. The first is the extraction of the URLs from the text, which is a tricky issue I’m not that interested in. I would do some research before using this in production. For now, I’ll use an extremely simple illustrative regex.
The second part is the code for doing the replacement within text nodes. I answered a related question the other day with some reusable code and now I’m getting to reuse it. Yay.