I have a string variable that could be something like this:
var content = "blah blah [media:id=1] blah blah blah [media:id=0] blah blah";
And an array of objects with information about the image, i.e.
var imageArray = [
{id:0, path:"/images/image.jpg"},
{id:1, path:"/images/anotherimage.jpg"}
]
I need a function to replace "[media: id = x]" with the corresponding image object path from imageArray using id, so my content variable will look like this:
"blah blah <img src='/images/anotherimage.jpg' /> blah blah blah <img src='/images/image.jpg' /> blah blah";
But I'm not sure where to start?
source
share