Convert all relative src attributes, not just images

This commit is contained in:
Kijin Sung 2017-07-05 17:32:11 +09:00
parent 9e78e9057f
commit e51836c0d9
2 changed files with 7 additions and 14 deletions

View file

@ -193,14 +193,11 @@ class HTMLDisplayHandler
// handles a relative path generated by using the rewrite module
if(Context::isAllowRewrite())
{
$url = parse_url(Context::getRequestUri());
$real_path = $url['path'];
$pattern = '/src=("|\'){1}(\.\/)?(files\/attach|files\/cache|files\/faceOff|files\/member_extra_info|modules|common|widgets|widgetstyle|layouts|addons)\/([^"\']+)\.(jpg|jpeg|png|gif)("|\'){1}/s';
$output = preg_replace($pattern, 'src=$1' . $real_path . '$3/$4.$5$6', $output);
$pattern = '/src=("|\'){1}(?:\.\/)?((?:files\/(?:attach|cache|faceOff|member_extra_info|thumbnails)|addons|common|(?:m\.)?layouts|modules|widgets|widgetstyle)\/[^"\']+)("|\'){1}/s';
$output = preg_replace($pattern, 'src=$1' . \RX_BASEURL . '$2$3', $output);
$pattern = '/href=("|\'){1}(\?[^"\']+)/s';
$output = preg_replace($pattern, 'href=$1' . $real_path . '$2', $output);
$output = preg_replace($pattern, 'href=$1' . \RX_BASEURL . '$2', $output);
if(Context::get('vid'))
{