添加amp调试开关

hotfix/远程访问多媒体中心
尹诚诚 7 years ago
parent 478a00de73
commit 732bb5108c

@ -22,6 +22,7 @@ class Index extends CI_Controller
$websitehost = $this->input->post('websitehost');
$template_name = $this->input->post('template_name');
$create_amp = $this->input->post('create_amp');
$debug = $this->input->post('debug');
if (empty($htmlsource) || empty($websitehost)) {
$this->output->set_status_header(500);
echo 'error:htmlsource or websitehost is empty!';
@ -139,7 +140,7 @@ class Index extends CI_Controller
//只返回AMP代码
if (!empty($create_amp)) {
$amp = $this->create_amp($html_object, $template_name, $websitehost);
$amp = $this->create_amp($html_object, $template_name, $websitehost,$debug);
echo json_encode(array('result' => 'ok', 'data' => array('amp' => $amp)));
return;
}
@ -177,7 +178,7 @@ class Index extends CI_Controller
要求: 图片文件必须带有域名,否则的获取尺寸会出错,如 https://data.asiahighlights.com/pic/abc.jpg
*/
//$htmlsource 移动端版本的HTML对象 $cache_path AMP文件保存路径
function create_amp($htmlsource, $site_code, $websitehost)
function create_amp($htmlsource, $site_code, $websitehost,$debug=false)
{
$html_object = str_get_html($htmlsource);
@ -263,6 +264,9 @@ class Index extends CI_Controller
$img_src_urls = parse_url($img_src);
$request_size[$img_src_urls['host']][] = $img_src_urls['path'];
}
if($debug){
print_r($request_size);
}
//请求图片尺寸
$image_sizes = array();
@ -277,6 +281,9 @@ class Index extends CI_Controller
}
}
}
if($debug){
print_r($image_sizes);
}
//获取图片尺寸 end

@ -25,7 +25,12 @@
<option value="cht">CHT</option>
<option value="ct">CT</option>
</select>
<select name="debug" id="debug" class="form-control" onselect="">
<option selected="" value="0">不调试</option>
<option value="1">开启调试</option>
</select>
<br/><br/>
<input type="submit"/>
</form>

Loading…
Cancel
Save