I’m currently working on a very large WordPress build that is heavily populated with posts. I’ve had a request come through where I have to do the following…
Remove all anchor tags that are wrapped around img tags.
For example, I need the following…
<a href="some-random-page"><img src="some-radom-image"/></a>
To become…
<img src="some-random-image"/>
Could this at all be done using an SQL update statement that I can run in phpMyAdmin as all WordPress posts are stored in the “posts” table.
Hope someone can help.
For match use :
(<a[^<]*>.*?)(<img[^>]*>)([^<]*</a>)
For replace use :
$2
Example : http://RegExr.com?37vbk
(replace dummy text in the example with your string)
You can do so with Dreamweaver. Export your db table. Open in Dreamweaver.
Find the following with “regular expression” option checked.
Now replace this with:
Now import the db table back to MySQL.