我不是正则表达式的专家,但我正在尝试将图像 URL 转换为另一个并删除高度和宽度属性......
$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;
回显结果并没有给我图像扩展名:
<img src="http://www.mysite.com/thumb.php?url=http://www.mysite.com/wp-content/uploads/2013/02/image.&width=500&height=500" />
我怎样才能做到这一点?