批量设置图片尺寸

ct-mobile-first
ycc 4 years ago
parent 131dba51fa
commit 0751c2b3fd

@ -497,6 +497,8 @@ class Information extends CI_Controller
} else if (strcasecmp($site_code, "ch") == 0 && !empty($auto_update_cache)) {
//读取模板生成PC和移动优先文件
$information_new = $this->Information_model->Detail($this->input->post('is_id'));
//设置图片尺寸
$information_new->ic_content=$this->html_optimize_lib->set_image_size($information_new->ic_content);
$this->make_www_cache('mobile', $information_new);
$this->make_www_cache('pc', $information_new);
} else if (strcasecmp($site_code, "cht") == 0 && !empty($auto_update_cache)) {
@ -578,6 +580,7 @@ class Information extends CI_Controller
return false;
}
if ($this->html_file_helper('find', $information->ic_url)) {
//用于批量更新
//设置图片尺寸
$information->ic_content=$this->html_optimize_lib->set_image_size($information->ic_content);
$this->make_www_cache('pc', $information);

@ -52,22 +52,24 @@ class html_optimize_lib
}
}
}
//print_r($request_size);
//print_r($image_sizes);
//把尺寸写入html内容中
foreach ($html_object->find('img') as $image) {
$img_src = $image->src;
if (!empty($image->originalsrc)) {
$img_src = $image->originalsrc;
}
if(!empty($image_sizes[$img_src])){
$image->width=$image_sizes[$img_src]->width;
$image->height=$image_sizes[$img_src]->height;
$img_src_urls = parse_url($img_src);
$img_src_index="https://".$img_src_urls['host'] . $img_src_urls['path'];
if(!empty($image_sizes[$img_src_index])){
$image->width=$image_sizes[$img_src_index]->width;
$image->height=$image_sizes[$img_src_index]->height;
}
}
return $html_object;
return $html_object->save();
//print_r($request_size);
//print_r($image_sizes);
}

Loading…
Cancel
Save