I have a page of images wrapped with links. Essentially I want to remove the links surrounding images, but keep the image tags in tact.
eg. I have:
<a href="something.html" alt="blah"><img src="image1.jpg" alt="image 1"></a>
and I want:
<img src="image1.jpg" alt="image 1">
I tried this code I found in my research, but it leaves a stray </a>
tag.
$content =
preg_replace(
array('{<a(.*?)(wp-att|wp-content\/uploads)[^>]*><img}',
'{ wp-image-[0-9]*" ></a>}'),
array('<img','" />'),
$content
);
I have no idea when it comes to regular expressions so can someone please fix my code? :-)