Modify Image Source With The_Content Filter?
Let’s give it a try: $str=”<img src=”http://myserver.mydomain/picture.png” />”; $pattern =’#<img src=”http://.*/(.*)” />#’; $replace=”<img src=”http://http://i0.wp.com/$1?quality=70&strip=all />””; $result = preg_replace($pattern, $replace, $str); The $pattern is quite simple and very specific. You might need to generalize it a bit more but it should show you the direction to go. E.g. it takes no care of possible whitespace. A … Read more