|
|
|
@ -228,6 +228,7 @@ class Index extends CI_Controller
|
|
|
|
|
$style_content = str_replace('!important', '', $style_content);
|
|
|
|
|
$amp_template = str_replace('/*@CUSTOM-CSS@*/', $style_content, $amp_template);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//获取图片尺寸,AMP要求必须填写width和height
|
|
|
|
|
|
|
|
|
|
//格式化图片URL
|
|
|
|
@ -255,6 +256,10 @@ class Index extends CI_Controller
|
|
|
|
|
if (!empty($image->originalsrc)) {
|
|
|
|
|
$img_src = $image->originalsrc;
|
|
|
|
|
}
|
|
|
|
|
if (strpos($img_src, 'facebook.com') !== false) {//facebook会添加一个跟踪代码,需要删除掉,否则获取图片尺寸会报错
|
|
|
|
|
$image->outertext = '';
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
$img_src_urls = parse_url($img_src);
|
|
|
|
|
$request_size[$img_src_urls['host']][] = $img_src_urls['path'];
|
|
|
|
|
}
|
|
|
|
@ -280,9 +285,13 @@ class Index extends CI_Controller
|
|
|
|
|
if (!empty($image->originalsrc)) {
|
|
|
|
|
$img_src = $image->originalsrc;
|
|
|
|
|
}
|
|
|
|
|
if(empty($image_sizes[$img_src])){
|
|
|
|
|
//如果尺寸不存在则跳过
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
$img_size = $image_sizes[$img_src];
|
|
|
|
|
$img_alt = $image->alt;
|
|
|
|
|
$img_class = $image->class;
|
|
|
|
|
$img_size = $image_sizes[$img_src];
|
|
|
|
|
if (!empty($img_size)) {
|
|
|
|
|
$image->outertext = " <amp-img layout=\"responsive\" class=\"{$img_class}\" alt=\"{$img_alt}\" src=\"{$img_src}\" width=\"{$img_size->width}\" height=\"{$img_size->height}\"></amp-img>";
|
|
|
|
|
}
|
|
|
|
|