Oh man I am completely lost with this. I been staring at code for days and havent gotten any farther then when I started.
What I'm trying to do:
I want people to submit comments on my site. They can include <img> tags. However, I need to parse these img tags so that I force the width to be less then 200. The layout for my website will get messed up if the image width goes over that.
What I'm trying to do is
preg_match_all(REG EXP IMAGE TAG SRC attributes)
count the matches
for each match
{
1. construct new image tag where width=200 if image width > 200, (this part I got already)
2. preg_match_all(REG EXP IMAGE TAGS GENERIC)
3. replace each instance of above IMAGE with the new image tag
}
in other words <img src="crap.jpg" width=800 height=300> will be replace with <img src="crap.jpg" width=200>
But the regular expressions are driving me insane, i need them to match single quotes, double quotes, no quotes, and if there are multiple images in the same string it only matches the last one.
Please help, I beg you
mookbuster