I was wondering if anybody could help me out with small regex problem:
I need to define what alignment was selected (image) and replace and then change piece of coding accordingly.
Anthony, please correct me if I’m wrong, but if the HTML is not well-formed XML (e.g. <img/> is not self-closing) won’t DOMDocument fail completely? It depends on the OP’s confidence in the HTML’s quality as well I suppose, but I’m guessing it’s going to include code he’s not responsible for, which may well be malformed.
I simply want to add a piece of html to the <img> tag. I have this wysiwyg that adds images, which works fine but the text around 'em is way too close.
So, depending on the alignment, I wanted to add padding to every image.
eg.
if align = left, then swap the second instance and add some css to the image
/<img(.*?)(align=“left”)>/
so the result will be something like <img … align=“left” style=“padding: 0 5px 5px 0”>