diff --git a/application/core/MY_Output.php b/application/core/MY_Output.php index 324e3191..bd2de1e0 100644 --- a/application/core/MY_Output.php +++ b/application/core/MY_Output.php @@ -65,9 +65,11 @@ class MY_Output extends CI_Output { } //解析html,生成不同版本的静态文件 - //替换图片地址,用CDN分发 + $html_object = str_get_html($output); if (!empty($html_object)) { + + //替换图片地址,用CDN分发 foreach ($html_object->find('img') as $image) { if (strpos($image->src, '/pic/') !== false) { $image->src = 'https://data.asiahighlights.com' . $image->src; @@ -75,11 +77,16 @@ class MY_Output extends CI_Output { $image->src = 'https://data.asiahighlights.com' . $image->src; } } + //保存PC端代码 $output = $html_object->save(); + + //生成移动版本 + foreach ($html_object->find('.hidden-xs') as $hidden_item) { + $hidden_item->outertext = ''; + } + $html_object->save($cache_path . '.mobile.htm'); } - //删除多余空格和换行符 - $output = str_replace(array(" ", "\t", "\n", "\r"), " ", $output); - $output = str_replace(" ", " ", $output); + ////// diff --git a/lib/simple_html_dom.php b/lib/simple_html_dom.php index 9a7b2f66..ce412794 100644 --- a/lib/simple_html_dom.php +++ b/lib/simple_html_dom.php @@ -1141,7 +1141,7 @@ class simple_html_dom $this->original_size = $this->size; //before we save the string as the doc... strip out the \r \n's if we are told to. - if ($stripRN) { + if ($stripRN && 1==2) { $str = str_replace("\r", " ", $str); $str = str_replace("\n", " ", $str);