14.9. How to remove links from images
You can achieve this by using regular expressions. Go to Find and replace in post’s content setting under Templates Tab of Site Settings Page and configure it as follows:
Regex: | Checked |
---|---|
Find: | <a[^>]+>\s*?(<img[^>]+>\s*?)<\/a> |
Replace: | $1 |
This will remove the links of the images. $1
in the replace box represents the img
element.
So, if there is a link with an image inside, the image will stay, while the link will be removed.
Please note that this regex may not work for you. If this is the case, you can use an online
regex tester such as Regex101 to create a regex and test it for your case.