I'm trying to figure out how can I extract a URL from the following string in JS.
var str = '[velocity type="youtube" id="239793212" img="http://website.com/wp-content/uploads/image-placeholder.jpg" alt="Play" color="#FFFFFF" bkg_color="transparent"]';
I would like to somehow pull only the http://website.com/wp-content/uploads/image-placeholder.jpg
value from this WordPress shortcode which is being read by the WordPress TinyMCE editor.
I should add that the string will not always be in the exact format and the position of img=""
will fluctuate.
Is there a way to parse this string as JSON or an array so I can access the value of img
?