PHP纠正TinyMCE URL转换
TinyMCE用于自定义CMS,将URL中的符号和转换为html实体,如下所示:PHP纠正TinyMCE URL转换,php,tinymce,Php,Tinymce,TinyMCE用于自定义CMS,将URL中的符号和转换为html实体,如下所示: <img src="https://maps.googleapis.com/maps/api/staticmap?markers=15.44,-14.57&zoom=14&size=250x180&sensor=false" alt="map" /> 此图像导致错误“Google Maps API服务器拒绝了您的请求。请求无效。缺少'size'参数。
<img src="https://maps.googleapis.com/maps/api/staticmap?markers=15.44,-14.57&zoom=14&size=250x180&sensor=false" alt="map" />
此图像导致错误“Google Maps API服务器拒绝了您的请求。请求无效。缺少'size'参数。”
我无法改变TinyMCE的行为(没有任何效果)
或者,我想在保存到DB之前使用PHP查找replace all href/src
如何在PHP中编写代码,在字符串$post中搜索href/src URL,并找到符号和html实体代码,并将其替换为“&”
我尝试了使用preg_replace的示例,但无法使其正常工作。我使其正常工作,希望它能帮助他人
$str = '<a href="https://some.com/?m=1&z=2&s=3&r=f">some text</a><img src="https://maps.googleapis.com/maps/api/staticmap?markers=136.22,-186.74&zoom=14&size=250x180&sensor=false" alt="map" />';
$re = '/(href|src)=("[^"]*")/';
preg_match_all($re, $str, $matches);
foreach ($matches[0] as $match){
$conv = str_replace('&', '&', $match);
$str = str_replace($match, $conv, $str);
}
echo $str; // & in url converted to &
$str='';
$re='/(href | src)=(“[^”]*”)/;
预匹配全部($re,$str,$MATCHS);
foreach($matches[0]为$match){
$conv=str_replace(“&;”、“&;”、$match);
$str=str\u replace($match,$conv,$str);
}
将url中的echo$str;//&;转换为&
Tinymce有时会因为旧版本的PHP而出现问题。我在安装上一个版本的PHP时解决了很多问题。