I'm not an expert with Regex, but I'm trying to convert an image URL to another and delete the height and width attributes...
$content = preg_replace('/src="([^"]*)(png|jpeg|jpg|gif|bmp)"/', 'src="http://www.mysite.com/thumb.php?url=$1&width=500&height=500"', $post_content);
$content = preg_replace( '/(width|height)=\"\d*\"\s/', "", $content);
echo $content;
Echoing the results doesn't give me an image extension:
<img src="http://www.mysite.com/thumb.php?url=http://www.mysite.com/wp-content/uploads/2013/02/image.&width=500&height=500" />
How can I do this?
src\s*=\s*"([^"]+\.(png|jpeg|jpg|gif|bmp))"