I'm looking for something, but don't exactly know what.
I have a shortcode, let's call it [shortcode].
Users will input HTML tags inside, mostly images, but also links, images in links, etc., for example:
[shortcode]
<img src="http://www.site.com/myimage.jpg" />
<a href="http://www.blabla.com"><img src="http://www.site.com/myimage2.jpg" /></a>
(...)
[/shortcode]
The point is I want to format URLs, differently, I want every img src to start with files/myimagescript?
So the code above should output:
<!--- shortcode code before input -->
<img src="files/myimagescript?http://www.site.com/myimage.jpg" />
<a href="http://www.blabla.com"><img src="files/myimagescript?http://www.site.com/myimage2.jpg" /></a>
(...)
<!-- shortcode code after input -->
So basically I need to simply change src of images. And it should work for any number of images, from 1 to unlimited.
I'm thinking about foreach PHP loop, but I'm not sure how to grab each img src line from shortcode and process it before displaying?